pbutton.setOnClickListener(new OnClickListener()
{ private AlertDialog show;
public void onClick(View arg0)
{
if ((input1.getText().length() == 0) || (input1.getText().toString().equals(" ")) || (input2.getText().length() == 0) || (input2.getText().toString().equals(" "))|| (input1.getText().toString().equals(""))||(input2.getText().toString().equals("")))
{
show = new AlertDialog.Builder(MainActivity.this).setTitle("Error").setMessage("Some inputs are empty").setPositiveButton("OK", null).show();
}
double result = new Double(input1.getText().toString())+ new Double(input2.getText().toString());
output.setText(Double.toString(result));
}
我也尝试过传递也不起作用的上下文