已经实现了 OnItemLongClickListener。当 LongClicked 列表项时,我启用了相关列表项的按钮。在 LongClicked 之后,按钮成功启用,但 onListItemClick 不会被触发。如果我在没有 LongClicked 的情况下 onListItemClick,它会成功触发。如果 LongClicked 在此之前触发,为什么 onListItemClick 不会触发?
OnItemLongClickListener listener = new OnItemLongClickListener(){
public boolean onItemLongClick(AdapterView<?> av, View v, int position, long id) {
Account a = null;
a = (Account) av.getItemAtPosition(position);
Toast.makeText(AccountActivity.this, "Long Clicked : " + a.getAccountName(), Toast.LENGTH_LONG).show();
v.findViewById(R.id.btn_delete).setVisibility(View.VISIBLE);
return false;
}
};
getListView().setOnItemLongClickListener(listener);
public void onListItemClick(ListView l, View v, int position, long id) {
// Do something when a list item is clicked
Account a = null;
a = (Account) l.getItemAtPosition(position);
Toast.makeText(AccountActivity.this, a.getAccountName(), Toast.LENGTH_SHORT).show();
}