如何转换下面的int以在文本视图中以文本形式显示总和的结果?

正在获取“无法在原始类型int上调用toString()”的想法-认为这就是toString的重点!?!

public void onClick(View v) {
    // TODO Auto-generated method stub
    txtAnswer = (TextView)findViewById(R.id.txtAnswer);
    editStones = (EditText)findViewById(R.id.editStones);

    int result = 10 + 10;
    txtAnswer.setText(result.toString());
}

最佳答案

txtAnswer.setText(String.valueOf(result));


或者这也可以:

txtAnswer.setText("result is : "+result);

09-25 22:23