The method dismissDialog(int) from the type Activity is deprecated
阿里云国内75折 回扣 微信号:monov8 |
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6 |
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 |
asked Nov 2 '11 at 8:18 skayred2,23432049 |
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
|
|
| 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 |
| 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 |
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 |
|
| answered Jan 9 at 22:51 ashishduh1,7241512 |
阿里云国内75折 回扣 微信号:monov8 |
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6 |