0

This is not deprecation-related. I get this error wherever I put the line addPreferencesFromResource(R.xml.preferences);, just after onCreate or in a seperate method called after.

I did include import android.preference.PreferenceActivity; but it shows up greyed as unused.

I'm using the latest Android Studio if it counts for something.

Carp Fisherman
  • 141
  • 1
  • 3
  • 17
  • What's the type of the class you're trying to add this in? – Voicu Jul 16 '13 at 01:59
  • I'm not exactly sure what to answer. I patched up the thing mostly from [this question's 3rd answer](http://stackoverflow.com/questions/6822319/what-to-use-instead-of-addpreferencesfromresource-in-a-preferenceactivity), but I also tried to put it in my main activity's onCreate, with the same result. – Carp Fisherman Jul 16 '13 at 02:07
  • I see. Post the full class code if you will. – Voicu Jul 16 '13 at 02:10
  • Excuse the mess, it's a bit of a patchwork for now... Features still being implemented and everything... http://pastebin.com/PFN320eF Faulty one's at line 154. Thanks for the help – Carp Fisherman Jul 16 '13 at 02:14

1 Answers1

1

The compilation error occurs because you're extending Activity and not PreferenceActivity.

So replace

public class MainActivity extends Activity {

with

public class MainActivity extends PreferenceActivity {

and you should be good to go.

Voicu
  • 16,921
  • 10
  • 60
  • 69
  • Yeah! Error's gone. For future reference, do you think I should get this part on a seperate java activity? – Carp Fisherman Jul 16 '13 at 02:23
  • 1
    I would say yes, in a different `PreferenceActivity`. I'm not sure what the best approach here is though. The link you mentioned in your comment has a lot of good advice on this manner. – Voicu Jul 16 '13 at 02:32