I am trying to add an alertdialog within an alertdialog.But not able to see the second alertdialog..please help me here is my code shown
AlertDialog alertDia
import android.widget.TextView;
import android.widget.Button;
import android.view.View;
import android.content.DialogInterface;
public class MainActivity extends AppCompatActivity {
Button click;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
click=(Button)findViewById(R.id.btnId);
click.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
txtSubmit();
}
});
}
protected void txtSubmit(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("This is alert title");
builder.setMessage("This is message for Alert dialog");
builder.setPositiveButton("Yup", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
AlertDialog.Builder builder1 = new AlertDialog.Builder(MainActivity.this);
builder1.setTitle("This is alert title inside");
builder1.setMessage("This is message for Alert dialog inside");
builder1.show();
}
});
builder.show();
}
}
The txtSubmit function calling from the onClick event listener.
Also for the second alert dialog need to open I have to pass
AlertDialog.Builder builder1 = new AlertDialog.Builder(MainActivity.this);
Here, we have to bind the this event using className
When we click on the yup button in the first dialog,it shows the second dialog that insides in the first one