java我想设置代码。tostring,但它不可用
在注释标记的代码行中,我想把townHallLvl放进去,但它必须是string,所以我尝试使用。toString,但它不可用。 有没有别的解决办法,或者我做错了什么
package com.example.安卓.planmyclash;
import 安卓.support.v7.app.AppCompatActivity;
import 安卓.os.Bundle;
import 安卓.widget.TextView;
public class MainActivity extends AppCompatActivity {
//set buildings' values
int townHallLvl = 1;
//declare ids
TextView townHallText = (TextView) findViewById(R.id.town_hall_lvl);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setValues();
}
public void setValues(){
townHallText.setText(); //this line <----
}
}
# 1 楼答案
快乐编码
# 2 楼答案
试试这个:
我希望它能完美地工作
# 3 楼答案
使用
以便将整数转换为字符串