Android: long click on a button -> perform actions

I’ve done it before, I just used:

down.setOnLongClickListener(new OnLongClickListener() { 
        @Override
        public boolean onLongClick(View v) {
            // TODO Auto-generated method stub
            return true;
        }
    });

Per documentation:

public void setOnLongClickListener
(View.OnLongClickListener l)

Since: API Level 1 Register a callback
to be invoked when this view is
clicked and held. If this view is not
long clickable, it becomes long
clickable.

Notice that it requires to return a boolean, this should work.

Leave a Comment