shared preferences/preference activity 是否允许页面内有 enabling/disabling 个片段?

Does shared preferences/preference activity allow for enabling/disabling of fragments inside the page?

我有一个 activity 扩展首选项 activity 成为设置页面。在设置页面内是一个编辑文本和三个不同的列表视图。我想对编辑文本的输入进行硬编码,以便在输入正确的 "password" (硬编码字符串)时,它会启用之前隐藏和禁用的列表视图。这可能同时发生吗?如何发生?

 private EditText password;
@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    password = (EditText)findViewById(R.id.adminpasswordsetting);
    getFragmentManager().beginTransaction().replace(android.R.id.content, new MyPreferencesFragment()).commit();

}

public static class MyPreferencesFragment extends PreferenceFragment{
    @Override
    public void onCreate(final Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences);

    }
}
private void setAdminSettings(){
    //set the password
    if(password.getText().toString().equals("helloworld")){
    //SharedPreferences.Editor editor = preferences.edit;
    }
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key){

}

我的 xml 偏好只是一个编辑文本偏好和三个列表偏好

这段代码可能不会 运行 'as is' ...所以不要复制粘贴它..但我在想一些类似的代码行(只是一个想法)

public class PrefsActivity extends PreferenceActivity {

    public PrefsActivity() {
        // TODO Auto-generated constructor stub
    }
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.prefs);
    ListPreference     lp1 = (ListPreference) findPreference(getString(R.string.lp1)); 
    CheckBoxPreference cb2 = (CheckBoxPreference) findPreference(getString(R.string.cb2)); 
    lp1.setEnabled(false);
    cb2.setEnabled(false);
    EditTextPreference etp1 = (EditTextPreference) findPreference(getString(R.string.mypassword)); 

    String  mypassword =PreferenceManager.getDefaultSharedPreferences(this).getString(getString(R.string.mypassword), "0");

  if ("THE_PASSWORD".equals(mypassword)) {
        lp1.setEnabled(true);
        cb2.setEnabled(true);
    }

}

}