I'm trying to display two alert boxes one from the other depending from a condition but i didn't get a solution, here is my code :
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();
}