調用的getText()這是我的代碼的值設置爲一個TextView無法在基本類型int
enter code here
public void addHours(View view){
final TextView mTextView = (TextView) findViewById(R.id.newHours_Value);
String hourValue = R.id.enterHours.getText().toint();
mTextView.setText("hourValue");
}
但R.id.enterHours.GetText()想出了一個錯誤
無法在原始類型上調用getText()int
請問我做錯了什麼。
您是在基本類型int調用的getText()。可能是在'mTextView'上調用它 –
相關:http://stackoverflow.com/questions/4953077/android-what-is-r-why-is-it-so-cryptic –
看到這篇文章[Android:Can not invoke toString( )在原始類型int] [1] [1]:http://stackoverflow.com/questions/3028974/android-cannot-invoke-tostring-on-the-primitive-type-int – Grmn