它使用函数 OnItemLongClickListener 但它也在释放按钮时运行 OnItemClickListener lv_driver.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) { builder = new AlertDialog.Builder(MyActivity.this); builder.setTitle("Be carefull "); builder.setMessage("Do you want to delete?"); builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { delData(i); } }); builder.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }); builder.show(); return false; } }); lv_driver.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Toast.makeText(MyActivity.this, "OnItemclick show ", Toast.LENGTH_SHORT).show(); } });}当按住按钮时,它会显示对话框确认删除,但当释放按钮时,它会从吐司中显示文本“OnItemclick show”。如何解决?
添加回答
举报
0/150
提交
取消