Skip to content Skip to sidebar Skip to footer

Preferencescreen Class Not Found

I have this in preferences.xml

Solution 1:

You're getting confused, you're trying to set the preference definition as the layout definition. First set a layout for the Activity, then bind your preferences XML:

  ...
  setContentView(R.layout.layout);
  addPreferencesFromResource(R.xml.preferences);
  ...

Solution 2:

The setContentView is not for PreferenceScreen, just "addPrerencesFromResource(R.**.yourPreference);" well. And your activity for the yourPreference view should inherits PreferenceActivity but not Activity.

Solution 3:

You don't need setContentView() method in PreferenceActivity.

publicclassPreferencesActivityextendsPreferenceActivity {
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
   }
}

Although it's Deprecated. use Preference Fragments instead.

Post a Comment for "Preferencescreen Class Not Found"