我创建了一个从strings.xml
with中获取 StringSharedPreferences
并将其显示在TextView
. 没有错误报告,但没有TextView
显示任何内容。有问题SharedPreferences
吗?字符串和TextView
是正确的。
public void setQuestion() {
TextView Question = (TextView) findViewById(R.id.question);
if (question == 0) {
SharedPreferences sharedPreferences =
getSharedPreferences("strings", Context.MODE_PRIVATE);
String myquestion = sharedPreferences.getString("AppQuestion1", "");
Question.setText(myquestion);
}
}