我有一个列表视图,我在其上附加了一个长按监听器。在这个长点击监听器中,我向用户显示了一个弹出菜单,其中包含“删除”等选项。当从该菜单中按下删除时,我需要引用触发长按侦听器的列表项的视图,以便我可以删除该列表项。我需要点击监听器内部的引用。我该怎么做,请帮忙。这是我的代码。
listview.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
CharSequence options[]={"Delete"};
AlertDialog.Builder symbolOptions=new Builder(context);
symbolOptions.setItems(options, new OnClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
CharSequence options[]={"Delete"};
AlertDialog.Builder symbolOptions=new Builder(context);
symbolOptions.setItems(options, new OnClickListener() {
public void onClick(DialogInterface thisDialog, int which) {
//TODO Auto-generated method stub
switch (which) {
case 0:
//Reference to the list item which initiated the long click listener
// Delete that list item
break;
default:
thisDialog.dismiss();
break;
}