我创建了一个从strings.xmlwith中获取 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);
}
}