当前位置: 代码迷 >> Android >> 请教关于listview的长按点击事件
  详细解决方案

请教关于listview的长按点击事件

热度:100   发布时间:2016-04-28 01:51:26.0
请问关于listview的长按点击事件
请问 ,通过自定义的adapter的方式 把listview的内容显示出来, 即public class leAdapter extends BaseAdapter{}

请问 怎么长按 某一项的时候,会弹出 对话框 呢?  也就是说 怎么为其 添加长按点击事件。

麻烦会的朋友帮忙回复。
------解决思路----------------------
设置onItemLongClick事件。注意返回值改成true
------解决思路----------------------
  registerForContextMenu(mListView);   
------解决思路----------------------
1.每条item添加长按事件。onItemLongClick。
2.使用ContextMenu。
------解决思路----------------------
lv.setOnItemLongClickListener(new OnItemLongClickListener() {

@Override
public boolean onItemLongClick(AdapterView<?> parent, View v,
int position, long arg3) {
// TODO Auto-generated method stub
tv = (TextView) v.findViewById(R.id.item_tv);
Toast.makeText(getApplication(), tv.getText().toString(), 1).show();
return true;
}
});
你要对话框还是土司还是肿么的随意。
  相关解决方案