Android – you cannot right-click a listview with fastscroll enabled
•
Android
Invalid Sign
<ListView
android:id="@+id/contacts"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cacheColorHint="@android:color/transparent"
android:fastScrollEnabled="true"
android:scrollbarStyle="outsideInset"/>
I've enabled quick scrolling for this listview. When I try to click the imagebutton on the right, the scroll bar will focus and the listview will start scrolling. I can't select the button on the right. Please help me
resolvent:
You need to override the listview class and its onintercepttouchevent method
public class CustomListView extends ListView {
public CustomListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
setFastScrollEnabled(false);
boolean possibleResult = super.onInterceptTouchEvent(ev);
setFastScrollEnabled(true);
boolean actualResult = super.onInterceptTouchEvent(ev);
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
return possibleResult && actualResult;
}
return super.onInterceptTouchEvent(ev);
}
}
It looks like:
However, the problem you observe is the expected behavior. The correct solution is to add padding at the end of the line
Take a look at Google's phonebook application, for example:
I hope it helps
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码