The method showDialog(int)
from the type Activity
is deprecated.
What‘s the reason? and how to solve it?
标签:des android blog http os io ar strong for
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 |
Google recommends that we use |
||||
add a comment
|
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
|
||||
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 |
|||||||||||||||||
|
Use DialogFragment over AlertDialog:
|
|||
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 |
|||||||||||||||||||||
|
The method dismissDialog(int) from the type Activity is deprecated
标签:des android blog http os io ar strong for
原文地址:http://www.cnblogs.com/flyingsir/p/3957883.html
okMessage
will be null. – hrnt Nov 2 ‘11 at 11:59target
which will be null if you load it from a Bundle. If the target of a Message is null, and you usesendToTarget
, you will get a NullPointerException - not because the Message is null, but because its target is. – hrnt Nov 2 ‘11 at 12:44