For settings I use PreferenceActivity
, on method addPreferencesFromResource()
; Eclipse says that it is outdated and you need to use the fragment
. What is better to use in which case? Can I continue to use PreferenceActivity
?
- How can I not understand, with the fragments to preferentially Activation? - Gorets
|
3 answers
Really specified method is deprecated, starting with API Level 11 - that is, with Android 3.0. Simultaneously, obsolete methods for creating dialogs such as Activity.showDialog()
have been declared obsolete, it is recommended to use fragments instead of them.
But there are a few significant points:
- Deprecation does not mean that the methods will not work - it means that the methods are replaced by other more new / stable / better. And perhaps in the future they will not work.
- Most Android devices still work on API Level <= 10, respectively, I would prefer to quietly continue to use obsolete methods with API 10.
Use to build the SDK Level 10 and the IDE will not swear at the obsolescence.
If you still want to use the SDK for ICS, then an example of using the PreferenceFragment here
- @Barmaley, do not you think that the 1st and 2nd paragraph contradict each other? Do not use obsolete methods. There is a library that allows you to cover the entire set of existing versions of the SDK. Yes, it will work slower, but hardly anyone will decide to write a server on the droid. - RomanoO
- @RomanoO, where did you actually find a contradiction here? In what? - Gorets
- No, do not contradict. Why write under Gingerbread on the API for ICS? Reasonable conservatism is needed, I personally prefer to always write under the API a step / level less than the most recent. - Barmaley
- This is logical, but the developers of the droid will take it and say: API <10 in android 5.0 is no longer supported. And what, you will rewrite all your applications? Not so this support package was released. - RomanoO
- The probability is exactly the same as the fact that in Android 6.0 they say that API <14 is no longer supported. This will not happen, otherwise the entire backward compatibility will fly and the entire market of Android applications will crash. I think Google understand that. Take the methods of the
java.util.Date
class - half of them were depreciated a hundred years ago, but there is still support in all versions of Java - Barmaley
|
Darya Ryazhskikh’s blog has such an article, look
|
Fragments must be used. For versions of Android <3.0 there is a support package .
- Give us some simple example of how to use them! - katso
- oneGoogle - android fragments exapmle - Gorets am
|