android 的textview怎么赋值就是不正确呢?
代码如下publicclassChartextendsActivity{privateStringname;privateintscore;privateTextView...
代码如下
public class Chart extends Activity {
private String name;
private int score;
private TextView textname;
private TextView textscore;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences ps = this.getSharedPreferences("chart", MODE_WORLD_READABLE);
name=ps.getString("name","");
score=ps.getInt("score",GameView.fscore);
textname=(TextView)findViewById(R.id.textscore);
textscore=(TextView)findViewById(R.id.textname);
textname.setText("玩家姓名:"+name);
textscore.setText("最高分数:"+score);
setContentView(R.layout.activity_chart);
}
}
我有试过直接settext一段字符串 可是还是有问题 展开
public class Chart extends Activity {
private String name;
private int score;
private TextView textname;
private TextView textscore;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences ps = this.getSharedPreferences("chart", MODE_WORLD_READABLE);
name=ps.getString("name","");
score=ps.getInt("score",GameView.fscore);
textname=(TextView)findViewById(R.id.textscore);
textscore=(TextView)findViewById(R.id.textname);
textname.setText("玩家姓名:"+name);
textscore.setText("最高分数:"+score);
setContentView(R.layout.activity_chart);
}
}
我有试过直接settext一段字符串 可是还是有问题 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询