I just start to study android, so have some problem
i have a file res/xml/settings.xml – settings from menu
create class Prefs and try to use settings from file above
package org.example.sudoku;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class Prefs extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
}
}
Problem, that addPreferencesFromResource cant be used and i need to use preferencesResId (according to comments), but if i write something like this
preferencesResId(R.xml.settings);
its not good.
Where is error in code? Could any1 help?
Also i try to learn android by using book – Hello Android.
preferencesResId()is not a method, it is a placeholder in conversation for your resource id (R.xml.settings).So although
Is deprecated, if you’re using this approach, this is still the most correct way – there isn’t another way using the deprecated approach.
I suggest you look at this SO question – it tells you what you should be using instead (PreferenceFragments). If you need a code sample, fire up Eclipse and the ADT plugin and make a
SettingsActivityvia thenew ActivityWizard.And as usual, here is the full JavaDoc for
PreferenceActivity.