0
有沒有辦法改變TextView的動態。 我有SharedPreferences,在「GameScreen」中可以。但我也想在「First Scree」(不是遊戲)中給用戶顯示 。 的問題是,它改變只有當我關閉打開的應用程序動態改變TextView android
mGameSettings = getSharedPreferences(GAME_PREFERENCES, Context.MODE_PRIVATE);
TextView goldmenu = (TextView) findViewById(R.id.goldmenu);
goldmenu.setTextColor(getResources().getColor(R.color.gold_color));
int curScore = mGameSettings.getInt(GAME_PREFERENCES_SCORE, 0);
String mmGold = String.valueOf(curScore);
goldmenu.setText(mmGold);
(編輯)
請更具體,並提供一些細節,你不知道的東西怎麼你爲什麼要使用共享偏好都在一個TextView – Eluvatar
呢!它的permenant數據...如果你正試圖讀取不同的活動中的值使用讓我們說靜態類常量......更具體一些,給一些細節,顯示一些代碼.... – laymelek
我想你應該學習如何在活動之間切換並在它們之間發送數據。看到這個教程,它可能對你有用:http://www.android-ios-tutorials.com/117/how-to-switch-between-different-activities-in-android/ – Houcine