标签:style blog color io ar sp div on cti
一、设置长按响应事件
在onCreate方法中添加下面代码:
this.getListView().setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), "longclick", Toast.LENGTH_SHORT).show(); //返回值:如果返回true,则不会触发点击事件,如果为fasle,则触发长按事件后,再触发点击事件 return true; } });
二、设置点击响应事件
在onCreate方法中添加下面代码:
this.getListView().setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), "click", Toast.LENGTH_SHORT).show(); } });
标签:style blog color io ar sp div on cti
原文地址:http://www.cnblogs.com/achsnw/p/4027966.html