我正在尝试根据条件显示两个警报框,但我没有得到解决方案,这是我的代码:
AlertDialog.Builder B = new AlertDialog.Builder(this);
final AlertDialog dialogue = B.create();
B.setTitle("Welcome !");
B.setMessage("Please enter a number :");
// Set an EditText view to get user input
final EditText input = new EditText(this);
input.setRawInputType(InputType.TYPE_CLASS_NUMBER);
B.setView(input);
B.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
if(input.getText().toString().trim().length()==0)
{
dialogue.dismiss();
final AlertDialog.Builder Be = new AlertDialog.Builder(this);
Be.setTitle("Error !");
Be.setMessage("Please enter a valid number !");
Be.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
inal AlertDialog dialogue2 = Be.create();
dialogue2.dismiss();
dialogue.show();}
});
}
else
{//Do some stuff}
});
B.show();
}