Carp Fisherman
Carp Fisherman

Reputation: 141

"Cannot resolve method 'addPreferencesFromResource(int)'"

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.

Upvotes: 0

Views: 1944

Answers (1)

Voicu
Voicu

Reputation: 17850

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.

Upvotes: 1

Related Questions