当我运行应用程序(使用数字进行简单操作)时,设计会崩溃。
。
代码就是这样:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et1 = (EditText) findViewById(R.id.et1);
//et2 = (EditText) findViewById(R.id.et2);
tv1 = (TextView) findViewById(R.id.tv1);
}
public void sumar(View view) {
String valor1 = et1.getText().toString();
//String valor2 = et2.getText().toString();
int nro1 = Integer.parseInt(valor1);
// int nro2 = Integer.parseInt(valor2);
//int resultado = nro1+nro2;
String res = String.valueOf(nro1);
tv1.setText(res);
}