user1026605
user1026605

Reputation: 1430

How to open a context menu by long pressing on a disabled button?

I have a listview for which I registered a context menu. On the list view row I have buttons. What I need is to be able to long press on a DISABLED button in order to access the row context menu.

I tried to add a long click listener on the button itself but it doesn't work when the button is disabled:

                button.setOnLongClickListener(new OnLongClickListener() {

                    @Override
                    public boolean onLongClick(View v) {
                        activity.openContextMenu(v);
                        return false;
                    }
                });

Any idea on how to do that ?

Upvotes: 0

Views: 123

Answers (1)

Ashish Pedhadiya
Ashish Pedhadiya

Reputation: 458

A disabled button cannot listen to any event, but you can customize your own button by extending Button class to make your own definition of disabling

Upvotes: 2

Related Questions