2

I would like to know how to use this method addPreferenceFromResource() as this is now deprecated in Preference Activity.

I went through these links,

Link 1

Link 2

Link 3

and also through the official documentation and other links, but I could not understand this as I am only a beginner.

Can anyone just provide me the source code of a simple preference like checkbox, it would be helpful to understand as I am only a beginner.

I do not need the explanation of the code, I would need only the source code of the XML as well as the Java Class.

I know this is some kind of home-work like thing, at-least some links would also do. Anything you are comfortable with.

Community
  • 1
  • 1

2 Answers2

1

It seems the preferred way to handle user Settings / Preferences is with the PreferenceFragment placed in a container within an Activity or FragmentActivity.

Here is a tutorial below on how to use the PreferenceFragment: http://www.cs.dartmouth.edu/~campbell/cs65/lecture12/lecture12.html

And the official documentation: http://developer.android.com/reference/android/preference/PreferenceFragment.html

This should fix your deprecated code problem.

Chackle
  • 2,249
  • 18
  • 34
0

This link might help you understand why got deprecated

https://stackoverflow.com/a/6504053/706833

As he say: In Android 3, API Level 11, the fragment-based preference model was introduced, thus deprecating methods that "is not relevant for a modern fragment-based PreferenceActivity."

Also, this link might help you https://stackoverflow.com/a/5501646/706833 to understand

hope it helps.

Community
  • 1
  • 1
Luis Pereira
  • 1,481
  • 3
  • 19
  • 46