我想问一下如何在列表视图中切换并选择一个事件.我的下面的代码正在工作.但是当OnItemLongClick触发时,OnItemClick也会触发.如何切换只会检测到一个事件的事件:
lstResult.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0,View arg1,int position,long arg3) { // TODO Auto-generated method stub //showToast(arg0.getItemIdAtPosition(position) + ""); String str = searchWhere(lstResult.getItemAtPosition(position) + ""); String word = lstResult.getItemAtPosition(position).toString(); showDialog(word,str); } }); lstResult.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0,long arg3) { // TODO Auto-generated method stub showToast(lstResult.getItemAtPosition(position) + ""); return false; } });
解决方法
在OnItemLongClick的末尾返回boolean true.