Reputation: 5440
I have a textview inside a viewpager.I have added a functionality to text view, such that user can hold the textview to hide, and appear after releasing the touch.
autoResizeTextView.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View arg0) {
arg0.setVisibility(View.INVISIBLE);
return true; // <- set to true
}
});
autoResizeTextView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
v.setVisibility(View.VISIBLE);
}
return false;
}
});
But this disabled viewpager's scrolling. How can I disable touch listener for textview while viewpager is scrolling?
I have set textview's height and width to fillparent btw.
Upvotes: 0
Views: 582
Reputation: 4076
If you want to disable the listener you can remove it from the TextView or set a boolean flag that makes it ignore all events. The ViewPager.OnPageChangeListener interface should allow you to determine the scroll state of the ViewPager using onPageScrollStateChanged() - if the state isn't SCROLL_IDLE, you should disable the TextView listener.
Upvotes: 1