Stephen
Stephen

Reputation: 8178

EditText OnLongClickListener triggering multiple events

I need to add an OnLongClickListener to an EditText view.

I can get it to work alongside some default events, but I don't want the default events to trigger at all. As default behavior a dialog will appear to select Input Method.

I thought I had found a solution with setting the android:longClickable attribute in the view xml to false, but apparently that did nothing.

Upvotes: 1

Views: 1218

Answers (1)

R Hughes
R Hughes

Reputation: 640

I'm not sure there's enough here for a proper answer, but here's a guess. If you return true, you've consumed the event and any further actions will not be taken. If you return false, you allow the OS to process the default LongClick action.

OnLongClickListener longClickListener = new OnLongClickListener() {
    @Override
    public boolean onLongClick(View v) {
        //doSomething();
        return true; //true = event consumed, false = event not consumed
    }
};

Upvotes: 5

Related Questions