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