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 |
share|improve this answer |
Android DialogFragment vs Dialog
up vote84down votefavorite 34 | Google recommends that we use android android-fragments android-dialog android-dialogfragment |
| add a comment |
share|improve this question | edited Jun 19 '13 at 21:50 samurai413x72 | asked Nov 2 '11 at 8:18 skayred2,23432049 |
4 Answers
activeoldestvotes
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
|
| show 9 more comments |
share|improve this answer | edited Nov 2 '11 at 12:41
| answered Nov 2 '11 at 11:50 PJL5,48234754 |
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 |
| add a comment |
share|improve this answer | edited Dec 19 '11 at 11:23
| answered Nov 2 '11 at 8:40 hrnt5,8401728 |
up vote8down vote | Use DialogFragment over AlertDialog:
A DialogFragment is a fragment that displays a dialog window, floating on top of its activity's window. This fragment contains a Dialog object, which it displays as appropriate based on the fragment's state. Control of the dialog (deciding when to show, hide, dismiss it) should be done through the APIhere, not with direct calls on the dialog.
|
| add a comment |
share|improve this answer | answered Jun 14 '13 at 23:27 user12817502,64421442 |
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 |
|
share|improve this answer | edited Jan 9 at 22:57
| answered Jan 9 at 22:51 ashishduh1,7241512 |