ray
ray

Reputation: 4250

What is the keyboard shortcut of long press in Android Emulator?

I am wondering what should be the keyboard shortcut of long press in Android emulator? I have a list of items. I have created a function to delete an item if long press over the item. But I can't test in my emulator. If I press the mouse for long time still it's triggering click event.

Upvotes: 4

Views: 10869

Answers (2)

slashdottir
slashdottir

Reputation: 8536

Make sure you remember to add the long-click listener to your button.

Example:

//without lambda
button.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {   
            Toast.makeText(getApplicationContext(), "Button Long Clicked", Toast.LENGTH_SHORT).show();
            return true;
        }
    });

//using lambda
button.setOnLongClickListener(v -> {
        Toast.makeText(getApplicationContext(), "Button Long Clicked", Toast.LENGTH_SHORT).show();
        return true;
    });

As seen here

Upvotes: 0

Zeeshan Mirza
Zeeshan Mirza

Reputation: 4589

Please see your code because long click with mouse is long press/ tap in emulators.

Upvotes: 7

Related Questions