public void onClick(View view)
{
double p,d;
try {
switch (view.getId()) {
case R.id.button:
p = Float.parseFloat(e.getText().toString());
d = p * 1.41;
e.setText("£" + p + " = " + "$" + d);
adb.setTitle("£ to $");
adb.setMessage("£" + p + " = " + "$" + d);
adb.show();
break;
case R.id.button2:
p = Float.parseFloat(e.getText().toString());
d = p * 1.14;
e.setText("£" + p + " = " + "€" + d);
adb.setTitle("£ to €");
adb.setMessage("£" + p + " = " + "€" + d);
adb.show();
break;
}
}
catch (NumberFormatException e)
{
d = 0.0;
}
}
};
On my code i have adb.setMessage
which repeats what e.setText("£" + p + " = " + "$" + d);
has in brackets. Is there any way to solve this issue?
I also have a problem where adb.show();
is repeated and would love to know how I can solve this. Thanks!