tags:

views:

85

answers:

4

I show to user a list of categories, he must choose one.
How to force the user to choose before pressing back?

+2  A: 

You could probably override the handling of the back button, but the more correct thing to do is simply handle the cancellation. In your onActionResult override, only react if the result argument is Activity.RESULT_OK (it will be Activity.RESULT_CANCELED if the user pushes the back button).

Richard Szalay
+3  A: 

Don't do this. Just handle the case when user doesn't select anything.

alex
+3  A: 

Assuming you're asking the user to choose via a Dialog, use the setCancelable(false) flag. According to the documentation, that prevents the use of the back button.

Steve H
+1  A: 

I would use a spinner and preselect a good default value. Forcing the user to do something should be only the last resort in your application.

Janusz