I ask for help, I make a simple calculator as the first program, but when I erase the last digit, the program crashes and I also could not add a comma to edit text, when I click on a comma on the numeric keypad, the program crashes.
public class MainActivity extends AppCompatActivity implements View.OnClickListener { private Button plus; private Button minus; private Button umnogenie; private Button delenie; private TextView text1; private EditText vvod1; private EditText vvod2; private double a,b; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); plus = (Button) findViewById(R.id.button9); minus= (Button) findViewById(R.id.button10); delenie= (Button) findViewById(R.id.button11); umnogenie= (Button) findViewById(R.id.button12); text1= (TextView) findViewById(R.id.textView); vvod1= (EditText) findViewById(R.id.editText); vvod2= (EditText) findViewById(R.id.editText2); plus.setOnClickListener(this); minus.setOnClickListener(this); delenie.setOnClickListener(this); umnogenie.setOnClickListener(this); vvod1.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s == null) a= 0; else a = Integer.parseInt(s.toString()); } @Override public void afterTextChanged(Editable s) { } }); vvod2.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s == null) b= 0; else b = Integer.parseInt(s.toString()); } @Override public void afterTextChanged(Editable s) { } }); } @Override public void onClick(View v) { switch (v.getId()){ case R.id.button9: text1.setText(String.valueOf(a+b)); break; case R.id.button10: text1.setText(String.valueOf(ab)); break; case R.id.button11: text1.setText(String.valueOf(a/b)); break; case R.id.button12: text1.setText(String.valueOf(a*b)); break; } } }