I've done an Activity with an image in full screen and below a textview with its description. What I want is to make invisible textview when I click on the image. I have placed a Toast and there goes the code, but is not invisible. What can be the error? thanks
public Object instantiateItem(ViewGroup view, int position) {
View imageLayout = inflater.inflate(R.layout.ampliar_imagen, view, false);
assert imageLayout != null;
imageView = (TouchImageView) imageLayout.findViewById(R.id.imagenFullScreen);
info = (TextView) imageLayout.findViewById(R.id.textoInfoImagen);
final ProgressBar spinner = (ProgressBar) imageLayout.findViewById(R.id.cargandoFoto);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(ImagePagerActivity.this, "CLICK", Toast.LENGTH_SHORT).show();
info.setVisibility(View.GONE);
}
});
imageLoader.displayImage(images[position], imageView, options, new SimpleImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
spinner.setVisibility(View.VISIBLE);
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
Toast.makeText(ImagePagerActivity.this, "Error al cargar la imagen", Toast.LENGTH_SHORT).show();
spinner.setVisibility(View.GONE);
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
spinner.setVisibility(View.GONE);
}
});
view.addView(imageLayout, 0);
return imageLayout;
}
XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/negro" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<imagenes.TouchImageView
android:id="@+id/imagenFullScreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:adjustViewBounds="true" />
<ProgressBar
android:id="@+id/cargandoFoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone" />
</FrameLayout>
<TextView
android:id="@+id/textoInfoImagen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/grisTransparente"
android:gravity="center_horizontal"
android:paddingBottom="3dp"
android:paddingTop="3dp"
android:text="AAAA"
android:textColor="@color/blanco"
android:textSize="13sp" />
</RelativeLayout>
You can define the textview in oclick event like this
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TextView info = (TextView) imageLayout.findViewById(R.id.textoInfoImagen);
info.setVisibility(View.GONE);//or you can invisible,
}
});