setText - 无法解析方法

End*_*ave 0 android

很确定这是一个愚蠢的问题,但我无法弄清楚这一点.

我试图获取由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转换为字符串,除非我使用视图?

Chi*_*ang 5

这是你想做什么的.

int year = 2014;
String yearString = Integer.toString(year); 
Run Code Online (Sandbox Code Playgroud)

因为stText mthod仅用于在android likeTextView,EditText,Button上的某些视图上设置文本.