Reputation: 157
I want to do in an Android application what I can do very easily in a "common" Java application : in a function triggered by a click on a menu item, I want to display a modal dialog box in which either the user can enter a text or choose between two or three answers (typically "yes", "no" and "cancel"). Once the user has made his input, the function can continue according to the choice made.
With the Fragment
class, I can display the dialog box. The problem is that it only appears after the completion of the function triggered by the user's click. This means that the code depending on the user input has to be executed in the class derived from the Fragment
class. And this has two disadvantages :
- it's more complex because a communication between the two objects has to be implemented,
- the reuse of the class is not easy since it's customized to communicate with only one class. Of course, it's possible to implement multiple communications towards as many class as we want, but the complexity will be even worse.
Is it possible to do what I want to do in a more simple way?
Thanks in advance for the time you will spend trying to help me.
Upvotes: 0
Views: 567
Reputation: 24233
Using a modal dialog is not allowed in android applications due to reasons like
I may be missing other points but these are the important ones.
So you should consider using callbacks to continue processing users input.
Upvotes: 1
Reputation: 642
Maybe try to use http://developer.android.com/reference/android/app/Fragment.html#getActivity()
Upvotes: 0