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
我沒有得到你嗎? –