请告知如何在列表视图上设置带有上下文菜单的 onLongtimeclicklistner?
以及如何将项目添加到上下文菜单?
有人可以告诉我有关如何有效执行此操作的步骤或任何建议吗?
listView.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
return false;
}
});
就那么简单:
myListView.setOnItemLongClickListener(new OnItemLongClickListener() {
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
Log.e("Log", "Item clicked " + position);
return false;
}
});