I have to restrict alert dialog getting closed on clicking on search button of the device, how to achieve it in android?
Scenario:
My app has one activity with list of data, user can select the data in the list and perform edit, delete etc… on it, if user tries to press edit,delete button of App without selecting an item from list then it pops up alert dialog with message saying “Please select an item” with Ok button.So when the alert dialog pops up if user presses Search button of the device , alert dialog gets closed, I just want to restrict closing of alert dialog.
Please help me to resolve this.
Set key Listener to your
AlertDialog Builderand track theKeyEvent.KEYCODE_SEARCH. Or OverrideonKeyDown()in your Activity..For
AlertDialog BuilderSomething like,