很确定这是一个愚蠢的问题,但我无法弄清楚这一点.
我试图获取由datepicker返回的字符串整数.此代码适用day于感兴趣的整数
dateButton = (Button) findViewById(R.id.dateButton);
dateButton.setText((Integer.toString(day));
Run Code Online (Sandbox Code Playgroud)
此代码为我提供了无法解析方法setText的错误
String yearString = "";
yearString.setText(Integer.toString(year));
Run Code Online (Sandbox Code Playgroud)
我不明白为什么我不能将int转换为字符串,除非我使用视图?
这是你想做什么的.
int year = 2014;
String yearString = Integer.toString(year);
Run Code Online (Sandbox Code Playgroud)
因为stText mthod仅用于在android likeTextView,EditText,Button上的某些视图上设置文本.
| 归档时间: |
|
| 查看次数: |
17072 次 |
| 最近记录: |