Questions tagged «onlongclicklistener»

10
如何在列表视图上实现长按监听器
我要添加OnLongClickListener到列表视图中。每当用户长按列表中的项目时,都应执行某些操作,但是我的代码无法捕获此侦听器。请让我知道我要去哪里了。类似的代码效果setOnItemClickListener很好。 这是代码: listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> arg0, View v, int index, long arg3) { // TODO Auto-generated method stub Log.d("in onLongClick"); String str=listView.getItemAtPosition(index).toString(); Log.d("long click : " +str); return true; } });

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.