In have implemented the OnItemLongClickListener. When LongClicked the list item, I enable a button of the relevant listItem. After LongClicked the button enables successfully but onListItemClick doesn’t get fired. If I onListItemClick without LongClicked, it fires successfully. Why does onListItemClick doesn’t fire if LongClicked fired before that?
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();
}
Try to implement like below,
setOnItemLongClickListener
setOnItemClickListener