How To Trigger Proper Longclick Event On Listview
i have to show Android Contextual action mode on long press of list view but when we long press then some multiple event trigger and Contextual menu hide so is there way to handle
Solution 1:
After search on stackoverflow i found my answer using this question implement GestureDetector on my listview an here is my code
set GestureDetector on listview
finalGestureDetectorgestureDetector=newGestureDetector(newMyGestureDetector());
View.OnTouchListenergestureListener=newView.OnTouchListener() {
publicbooleanonTouch(View v, MotionEvent event) {
return gestureDetector.onTouchEvent(event);
}};
mMessageListView.setOnTouchListener(gestureListener);
and this code of MyGestureDetector
classMyGestureDetectorextendsSimpleOnGestureListener{
@OverridepublicvoidonLongPress(MotionEvent e) {
super.onLongPress(e);
ListViewlv= mMessageListView;
intpos= lv.pointToPosition((int)e.getX(), (int)e.getY());
if (listMsg.get(pos).type==ChatItem.ITEM) {
mMessageListView.setItemChecked(pos, !adapter.isPositionChecked(pos));
}
}
}
i share this ans so it can helpful for other share
Post a Comment for "How To Trigger Proper Longclick Event On Listview"