Android - Can I use setOnLongClickListener and setOnClickListener for same button?
android, java, onclicklistener
Solution
return TRUE in your `onLongClick` method so that the event will be consumed.
readDbButton.setOnLongClickListener(
new View.OnLongClickListener() {
public boolean onLongClick(View view) {
//do something
return true;
}
}
);
Problem
Can I really use these setOnLongClickListener and setOnClickListener for same button? Because if I long click the button both longclick and normal click will be executed and I dont know why. Can I really do this? Please help me:) ``` readDbButton.setOnLongClickListener( new View.OnLongClickListener() { public boolean onLongClick(View view) { //do something return false; } } ); readDbButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { //Do something else } }); ```