0

CONTEXT:

  • I have a simple ListActivity (call it "Activity1") that contains a ListView and a number of menu items.
  • Clicking an item in the ListView shows a popup dialog.
  • Clicking a menu item button (let's call it "Button") in the ActionBar starts an Activity (let's call it "Activity2") using startActivityForResult()

PROBLEM: If the user touches a ListView item, generating an onListItemClick() event in the ListActivity and then really quickly touches Button, a onOptionsItemSelected() event is posted to the message queue and processed in due course. This results in the following odd behaviour:

  1. User touches ListView item
  2. User touches Button
  3. User sees dialog generated by onListItemClick() for a split second
  4. Activity2 started by onOptionsItemSelected() starts over top of the dialog
  5. When user finishes with the Activity2, he returns back to the dialog, not right back to Activity1

This is very odd and unsettling. In my experience doing UIs in older GUI frameworks, the GUI framework never allowed the second event to post to the queue so you never had to worry about these things.

QUESTION: Is there a "preferred" design pattern to prevent the user from being able to press Button and have it start Activity2 when my app is already in the process of showing a dialog in response to the ListView item select?

Disable the entire Activity1 view hierarchy until the dialog ends??

0xbe5077ed
  • 4,217
  • 1
  • 28
  • 62
  • RATS. This looks like a dupe of [this issue](http://stackoverflow.com/q/5608720/1911388) and [this issue](http://stackoverflow.com/questions/8077728/how-to-prevent-the-activity-from-loading-twice-on-pressing-the-button) where people are trying to suppress "double clicks" on buttons. – 0xbe5077ed Jan 19 '13 at 04:51
  • Here's another post dealing with the same issue: http://stackoverflow.com/q/11031814/1911388. – 0xbe5077ed Jan 20 '13 at 18:38

1 Answers1

0

Write in your ToS that users with 2 thumbs per hand should use the app with caution. More seriously, maybe you can check if your dialog is open before starting your activity with either a boolean or Dialog.isShowing()

ben
  • 1,151
  • 10
  • 20