我想总结两个EditText
中输入的数字,然后当按钮被点击时,我想总和显示在第三个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);
检查我的回答如下。 – Aniruddha