我只想问我是否在int
结果中设置了正确的值,因为每当我运行应用程序时,我都textview
不会输出ans*ans2
.
TextView tv2 = (TextView) findViewById(R.id.tv2);
EditText et1 = (EditText) findViewById(R.id.first);
EditText et2 = (EditText) findViewById(R.id.second);
String temp = et1.getText().toString();
String temp2 = et2.getText().toString();
int ans = Integer.parseInt(temp);
int ans2 = Integer.parseInt(temp);
int result = ans * ans2;
tv2.setText("" + result);