我想对两个输入的数字求和,EditText
然后单击按钮时,我希望在第三个显示总和,EditText
但似乎出了点问题。
这是我的代码:
result = (Button)findViewById(R.id.btn1);
nb1 = (EditText)findViewById(R.id.nb1);
nb2 = (EditText)findViewById(R.id.nb2);
nb3 = (EditText)findViewById(R.id.nb3);
}
public void result (View v){
String n1 = nb1.getText().toString();
int n11 = Integer.parseInt(n1);
String n2 = nb2.getText().toString();
int n22 = Integer.parseInt(n2);
nb3.setText(n11 + n22);
改变这个
nb3.setText(n11 + n22);
到
nb3.setText(String.valueOf(n11 + n22));
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句