here is my code but when i pressed the button without give the number app stopped whole day now please tell me what can i do for this The code is given below
public class MainActivity extends Activity { TextView result;
EditText editText1, editText2;
Button btnadd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText1 = (EditText) findViewById(R.id.editText1);
editText2 = (EditText) findViewById(R.id.editText2);
btnadd = (Button) findViewById(R.id.btnadd);
result = (TextView) findViewById(R.id.textviewresult);
btnadd.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view) {
int a = Integer.parseInt(editText1.getText().toString());
int b = Integer.parseInt(editText2.getText().toString());
int add = a + b;
result.setText("Answer: " + String.valueOf(add));
}
});