The method showDialog(int) from the type Activity is deprecated in android?
up vote6down votefavorite |
The method What‘s the reason? and how to solve it? |
7down voteaccepted |
What‘s the reason? http://developer.android.com/reference/android/app/Activity.html#showDialog(int) Android DialogFragment vs Dialog How to solve it? Use the new DialogFragment class with FragmentManager instead; this is also available on older platforms through the Android compatibility package. http://android-developers.blogspot.in/2012/05/using-dialogfragments.html
|
Android DialogFragment vs Dialog
up vote84down votefavorite 34 |
Google recommends that we use android android-fragments android-dialog android-dialogfragment
|
|||
add a comment |
4 Answers
up vote30down voteaccepted |
Yes use With regards handling events in your fragment there would be various ways of doing it but I simply define a message In the dialog hold a message and instantiate it in the constructor:
Implement the `onClickListener‘ in your dialog and then call the handler as appropriate:
Edit And as
Then in
|
||||||||||||||||||||
|
up vote15down vote |
I would recommend using Sure, creating a "Yes/No" dialog with it is pretty complex considering that it should be rather simple task, but creating a similar dialog box with (Activity lifecycle makes it complicated - you must let The nice thing is that you can usually build your own abstraction on top of
|
||||||||||||||||
|
up vote8down vote |
Use DialogFragment over AlertDialog:
|
||
add a comment |
up vote7down vote |
You can create generic DialogFragment subclasses like YesNoDialog and OkDialog, and pass in title and message if you use dialogs a lot in your app.
Then call it using the following:
And handle the result in
|
||||||||||||||||||||
|