Button myButton = findViewById(R.id.my_button); myButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { // Perform your action here return true; } });
Button myButton = findViewById(R.id.my_button); myButton.setOnLongClickListener(null);In this example, we simply unset the long-click listener from a button named "myButton". This is done by passing null as the argument to the setOnLongClickListener function. Package Library: android.view