Android: Associate an AlertDialog with a specific view - android

I have tabs that when tapped will show a view for each tab. Is it possible to create an AlertDialog that is specific to a particular view and only shows when the view is shown? So if the user taps on one tab, they would see an AlertDialog but if they tap on a different tab, the AlertDialog will not show. I don't believe its possible because I believe an AlertDialog is global within the app and when shown comes to the foreground making it impossible to tap on anything else until the dialog is dismissed. But maybe I'm wrong.

No, it is not. You may try to switch to Fragments and FragmentDialog as that would allow you to 'bind' dialog to a fragment, and each fragment can sit on separate 'tab' of your app (yet, you'd need to rework your app anyway). If you want to use 'traiditional' dialog, then you have to add a logic yourself, and not show it if different than expected tab is visible.

Related

Re-display parent dialog after child dialog closes

In my app, I display a custom Dialog (using DialogFragment), which on certain action causes another custom Dialog to be shown (using another DialogFragment). This all works fine. However when the "child" dialog is closed, I want to return to the parent dialog (which is closed/hidden when the child is displayed).
I do not want just display another instance of the same dialog, as I need to maintain states and behaviours of the parent prior to the child being open. Therefore I need to re-display physically the same dialog.
I can't seem to find a way of doing so.
Coming back to it as I now got a solution that seems to work. Apparently, using dialog directly will close the previous dialog when a new one is opened. Yet, when using DialogFragment, the previous fragment stays on screen when the new fragment is displayed. Then when the dialog on the new fragment is closed the previous fragment is still visible - exactly what I need.

How to Display two alert dialogs in specific order?

I have two alert dialogs. Whenever app opens, the first dialog is shown. After some time, the second dialog is shown. But here problem is recently created dialog(second one) is in front. But I want the fist created dialog is in front and second one is behind the first one.
The problem with the dialog box is that you can not display two dialog box at a same time. You must hide first dialog box in order to display second one.
You can only display one dialog at the time, but you can "work around" this. When you are about to display your second dialog, you hide your first dialog, but your application remembers that the first dialog was open, so when you hide your second dialog you displays the first dialog again. In reality this will go so fast so the user is fooled that the dialog is layered over eachother(if they have the same dimensions).
But you cannot display a dialog on top of another dialog.
You can display first dialog in front :
When you are calling to display second one at that time call first dialog again so, that is in from view of your screen.
Let me know you understand this or not.. otherwise i will provide code for it..
You cant make two dialog active at same time either one should active and the other should inactive.In your case if you want the second should come background of fist then you have to call first dialog from the second.

Dialog with outside touchable

In an android application, I want to display a Dialog on screen and in the same time to allow user to click on the application's UI when the the Dialog is open
can this be done?
if no, what can I use instead of Dialog?
I don't think you can do this with Dialog. But you can do it with PopupWindow using PopupWindow.setOutsideTouchable(true);.
Showing up a dialog over your Activity, will make your Activity go into onPause() so you won't be able to actually handle things inside that activity anymore until the dialog is dismissed.
If you want to have some view, overlay your original activities view you'll be looking for into the direction of FrameViews, which can overlap other Views.

How to apply such like design on Default Dialogs

I want to show two Dialogs (default) at the same time, no matter if second one is shown then previous lost its focus but should remain on the Screen. I tried by many ways such as:
1) Creating two Alert Dialogs
2) Creating one Alert Dialog and other one Activity as a Dialog
but i never achieved my desired task. Image is shown below that just describes how i want to show such Dialogs (default) and layout would be same as to the Default dialog but here i just describe how should the dialogs be laid out.
It's not possible to show two dialogs at the same time in the same activity.
If you do want something that looks like a second dialog, I suggest you create a layout inside the first dialog that is hidden until you make some selection.

Stacking Dialogs in Android

Is there a way to control the relative stacking of Dialogs produced by your own Activity? For instance, there are some more important Dialogs which I would like to ensure are on top and if another Dialog wants to pop up I would want it to pop under the important Dialogs.
Example: I want to present to the user an important dialog, Dialog A. The activity realizes that there is a dialog, Dialog B, of lesser importance to display to the user. Is it possible to specify Dialog B to be under Dialog A so that when Dialog A is cleared, Dialog B will be seen by the user?
I know that the onDismiss interface exists, but this necessarily ties Dialog A and Dialog B together. I want the Dialogs to be independent and would prefer to use a higher level abstraction like the window stack responsible for ordering the Dialogs.
There no such way as far as I know.

Categories

Resources