I am making android calculator app for class assignment. When i press plusminus (+/-) key first and then input any numeric key; my application stops working. But when i input numeric key and then press plusminus button it works fine.
else if (v.getId() == R.id.plusminus){
Double newNumber = Double.parseDouble(textdisplay.getText().toString());
total = newNumber * (-1);
textdisplay.setText(total.toString());
}
Please check your String from textdisplay to be empty. Because Double.parseDouble will throw a Exception when the String is empty or not numeric.
Please also have a look at the Double Documentation here LINK
Double.parseDouble(String s)