Android获取长按按键响应

Android获取长按按键响应
http://www.2cto.com/kf/201312/261719.html

Android下Listview的onItemClick以及onItemLongClick等易模糊问题验证
http://mypyg.iteye.com/blog/850624

 

ListView的 OnItemLongClick

listView.setOnItemLongClickListener(new OnItemLongClickListener() {

@Override
public boolean onItemLongClick(AdapterView<?> arg0, View view,
int position, long id) {
// TODO:XXX
return false;
}
});

另外还要

设置button属性: 

 
  1. android:focusable="false"  
  2. android:longClickable="true"  

否则无法收到long click。 


 Activity or View 的 onKeyLongPress()方法:

@override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
return super.onKeyLongPress(keyCode, event);
}
posted @ 2014-04-29 11:44  petercao  阅读(2212)  评论(0编辑  收藏  举报