Display Android dialog box on top of another?

I have two warning dialogs, dialog A and dialog B. By clicking on one of the dialog buttons A, you will open the dialog box B. Then I want you to have a button that cancels dialog B and returns to dialog A. Is there way to do this separately from dialog B executing showDialog (dialogA)?

This works, but you can see dialog A reloading instead of just returning to the already existing dialog A. Performing a reject in dialog B just rejects both of them.

A small question, but I would like to see if there is a way to stack them on top of each other.

thanks

+4
source share
4 answers

Using the basic locks of the dialog box, it is impossible to have their stack, you will need to re-show the first dialog box. The reason for this is that when you click on the dialog button, it internally rejects the dialog as part of the process to invoke the click handler that you assigned to each button in the dialog box API.

One way is to create a custom dialog layout that does not have firing behavior by customizing your own buttons in the layout, rather than using methods created by dialog box construction methods. Then, in the click handler for your own buttons, just show the second dialog without letting go of the first. http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog

+4
source

As already mentioned, you cannot do this with standard dialogs. But you can do this by making the first dialogue active, so that it looks like a dialogue, and the second is a dialogue. Just set the activity theme in your layout like this:

<activity android:theme="@android:style/Theme.Dialog"> 

See this topic about creating an activity that looks like a dialog. fooobar.com/questions/31769 / ...

+2
source

reject the dialogue from the inside out.

Edit, here is an even clearer code.

  alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); return; } }); alertDialog.show(); 
+1
source

You have to use your own layout of one view / button inside , and based on this click of the mouse / button you can create another dailog without canceling the first one, if you use builder.setNegativeButton or builder.setPositiveButton your current dialog will be closed , my working code is like,

 AlertDialog.Builder builder = new AlertDialog.Builder(ActivityAppImages.this,R.style.your_style); LayoutInflater inflater = getLayoutInflater(); View dialoglayout = inflater.inflate(R.layout.your_custom_layout, null); final Button mButtonCreateOtherDailog = (Button)dialoglayout.findViewById(R.id.txt_create_second_dailog); mTextView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //create your other dailog here } }); builder.setView(dialoglayout); builder.show(); 
+1
source

Source: https://habr.com/ru/post/1385254/


All Articles