How do I implement 开发者_如何学Pythona long touch event into my ListView? The only useful MotionEvents I see are ACTION_DOWN and ACTION_UP (there's no ACTION_STILL_DOWN event).
implement the OnItemLongClickListener interface in your ListActivity or you can use
getListView().setOnItemLongClickListener(new OnItemLongClickListener(){})
in the inner class way
ListActivity has a ListView, which you can get with:
ListView lv = getListView();
Then you can create a listener like so:
lv.setOnItemLongClickListener( new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick( AdapterView<?> av, View v, int pos, long id ) {
onLongListItemClick(v,pos,id);
return false;
}
} );
You then create your handler method:
protected void onLongListItemClick(v,pos,id) {
Log.i( TAG, "onLongListItemClick id=" + id );
}
Take a look at this discussion from the Android Developers google group
Try setting OnLongClickListner on listview. See this.
You can implement base-adapter or array-adapter for fix your issue
In getView() method of adapter you will get view onject and on view object you can set all event like click, Touch, LongTouch and more.
精彩评论