0
您好我试图从列表视图中保存用户首选项我想要它存储选定的内容,然后当应用程序再次加载检查偏好选择的方法if it = team then做一些事情,但目前它没有加载任何关于我做错的想法。当我退出选择的方法,它说空android共享首选项检索
继承人我的代码
preferences.edit().putString("ChosenMethod", "Team").commit();
preferences.edit().putString("ChosenTeam", ChosenTeam).commit();
preferences.edit().putString("ChosenTeamId", ChosenTeam).commit();
preferences.edit().putString("ChosenLeagueId", ChosenTeam).commit();
preferences.edit().putString("ChosenDivisionID", ChosenTeam).commit();
然后在introActivity我已经把这个这个
protected void checkPreferences(){
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
Log.v("myapp", "prefs = " + preferences);
String ChosenMethod = preferences.getString("ChosenTeam", chosenMethod);
Log.v("myapp", "ChosenMethod = " + ChosenMethod);
if (ChosenMethod != null){
Intent intent = new Intent(TheEvoStikLeagueActivity.this,Activity.class);
}
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
checkPreferences();
SharedPreferences preferences = _activity.getSharedPreferences(“SHARED_PREFERENCES_NAME”,android.content.Context.MODE_PRIVATE); String ChosenMethod = preferences.getString(“ChosenMethod”,ChosenMethod);继承人我放了n它不喜欢括号中的选择方法 – iamlukeyb
我没有得到你吗? –