Here are my codes
public void onClick(View v)
{
if (v == buttonOne)
{
TextView output = (TextView)findViewById(R.id.output);
output.append("1");
}
else if (v == buttonTwo)
{
TextView output = (TextView)findViewById(R.id.output);
output.append("2");
}
else if (v == buttonThree)
{
TextView output = (TextView)findViewById(R.id.output);
output.append("3");
}
else if (v == buttonFour)
{
TextView output = (TextView)findViewById(R.id.output);
output.append("4");
}
else if (v == buttonFive)
{
TextView output = (TextView)findViewById(R.id.output);
output.append("5");
}
else if (v == buttonSix)
{
TextView output = (TextView)findViewById(R.id.output);
output.append("6");
}
else if (v == buttonSeven)
{
TextView output = (TextView)findViewById(R.id.output);
output.append("7");
}
else if (v == buttonEight)
{
TextView output = (TextView)findViewById(R.id.output);
output.append("8");
}
else if (v == buttonNine)
{
TextView output = (TextView)findViewById(R.id.output);
output.append("9");
}
else if (v == buttonZero)
{
TextView output = (TextView)findViewById(R.id.output);
output.append("0");
}
else if(v == buttonEnter)
{
TextView output = (TextView)findViewById(R.id.output);
temp = Integer.parseInt(output.getText().toString());
compareNumber(temp);
output.setText("");
}
}
I am trying to compare number using button. For example, if I press buttonOne it append 1 to stack. It works completely fine when enter is pressed after one or more number is clicked, but the application stops when I left the EditText without entering any numbers and press buttonEnter.
Please help!