Dan
Dan

Reputation: 2344

Can OnLongClickListener for Android be used in an AlertDialog?

I have a list of options that are shown in an AlertDialog. The AlertDialog populates the list from a SharedPreferences file. Currently the user makes a selection, the AlertDialog closes and depending on the choice some edit text fields are filled in.

I would like to add an OnLongClickListener call to each option in the list, which when utilized would pop up another AlertDialog, over the top of the existing one, with a simple "are you sure you want to delete this?" question, then a yes and no button.

The dialog creation is simple, I just want to know if the OnLongClickListener can be applied and if AlertDialogs can be down on top of each other?

Upvotes: 0

Views: 631

Answers (1)

tjk213
tjk213

Reputation: 146

my answer here may help with adding an OnLongClickListener. The code I added is at the bottom of my response.

You can accomplish what you want by setting a new OnShowListener on your dialog and overriding the onShow() method

Upvotes: 2

Related Questions