Reputation: 1736
I am building an app with fragment. I have one ImageView java file in that I am displaying only image.
When we click on image it will close that particular fragment and open the previous fragment. Working fine...!!! (For image I have used onClickListener)
But when I click on that view it goes two fragments back. (For view I have used onTouchListener)
The code is:
View v1 = inflater.inflate(R.layout.attachment_image, null);
v1.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
getFragmentManager().popBackStack();
return true;
}
});
Upvotes: 2
Views: 1783
Reputation: 2045
Try this:
View v1 = inflater.inflate(R.layout.attachment_image, null);
Imageview image = (Imageview) v1.findViewById(R.id.img_blabla);
image.setOnClickListener( new OnClickListener() {
public void onClick(View v) {
getFragmentManager().popBackStack();
}
});
Upvotes: 2