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:
- User touches ListView item
- User touches Button
- User sees dialog generated by
onListItemClick()
for a split second - Activity2 started by
onOptionsItemSelected()
starts over top of the dialog - 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??