Popup window using Fragment - android

I want to create a pop-up window (with black transparent background around it) that would appear above the application activity screen (by clicking on a button). This pop-up would contain a video player, a list of videos to be played and some other elements.
This pop-up has to be a fragment since I need to re-use it from other app fragments.
So my question is : what is the best way to achieve that? I personally see 2 options :
1) adding the pop-up as a fragment on the layout and to show + activate it whenever I need. But in that case, how can I put a black transparent background around it that would fill the whole screen?
2) using DialogFragment but it seems that this class is not very well-designed for this kind of stuff.
What do you think?
Thanks in advance.

DialogFragments are the suggested way to launch Dialog views from within a Fragment, so this is the solution I would suggest for you.
You can do pretty much anything you need within the DialogFragment. You will be in full control of the UI using this method.
Here is a SO discussion of the same point, with good info: Android DialogFragment vs Dialog

Related

Android dialog : Is there a way to make background android UI clickable while dialog is displayed?

Currently, I am using Libgdx for making app with lots of animation. I am trying to use android Dialog for showing paragraph with html tags through Interface. While, I can change dim color of background UI back to normal with following code.
paragraphDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
Is there anything I can do to make background UI work? (Button click, textview focus etc)
And, I have tried GlyphLayout of Libgdx for paragraph. It frequently crashes & also doesn't support html tags. I am using dialogs, as it is pretty easy to use xml layout easily with dialogs. If there are any other options, Please suggest.
Thanks,
your dialog is blocking the entire screen, doesn't matter if the edges/background are somewhat transparent or not 100% alpha, it is still the view that is currently on top. therefor, you can't click on it directly.
i think the best way to achieve your goal is with a fragment. not a dialog.

android semi dialog semi activity - activity with dialog style, fullscreen dialogfragment

I'm working on my small app and I have terrible problem with dialogs. Partially my question will be technical, partially general.
For example I have the following scenario: 1) user select file type 2) user select file 3) user select some additional options - list of about 5/6 options.
I'm wondering if to do this as some kind of three steps wizard (for each step separate dialog) either as one activity with three buttons/elements for selecting the appropriate elements. How do you think? I would like to have my app giving some kind of light appearance to users, thus I would prefer not to have heavy things. have you seen any good examples of more complicated dialogs/activities? Any official guide for more complicated dialogs?
Moreover some technical questions:
1) Is that possible to have activity (full screen) looking as dialog (style)? If yes, how?
2) As for now I use DialogFragment. However android by default sets its dimensions in the way that there is no need to resize them when changing screen orientation (screen smaller dimension is the base for setting dialog size). In consequence when having screen in vertical orientation huge part of screen is not used by dialog. How to change that to have dialog occuping almost the whole screen, but also resizing correctly when changing screen orientation and if possible with still keeping setRetainInstance(true) (less problems with dialogs when changing orientation)?
use the following line of code in your activity below setContentView(R.layout.activity_main);
setTheme(android.R.style.Theme_Dialog);
refer following link,
Android: how to create a transparent dialog-themed activity

Android - Show more information on a popup

I'm developing an app that includes reviews of items and due to my design, I want to only show all the reviews in a popup window like in Google Play Store:
What should I use to create that white panel that appears over the current window and contains the necessary information? This should be simple but I'm a newbie and I can't seem to figure out what this "widget" is. Please help me if you are familiar with this so I can use this cool design pattern. Thanks.
It seems you want to display a layout as a popup in another activity.
If you want to do this using an Activity instead of a Dialog, you can do this by setting the activity's theme to android:theme="#android:style/Theme.Dialog" in the manifest - this will make the activity appear like a dialog (floating on top of whatever was underneath it).
A better way to do it would be using a DialogFragment. You can display information in the form of a popup and it will have its own lifecycle. That will be much better than displaying an activity like a dialog
Ram kiran's answer is a good one and one which I like to give also. But just so you have another option to look at you can consider PopupWindow
As stated in the docs, it is
A popup window that can be used to display an arbitrary view. The popup window is a floating container that appears on top of the current activity.
I've used this and it works out nicely in some situations. It really depends on what your exact needs are as to which will work best for you.

Can we interact with background activity when displaying a dialog over it in android

I want to display a dialog over an activity but still want to interact with background activity to perform something, while the dialog is being displayed. How can this be done?
You could start a new Thread to perform this action. What I recommend is to implement an AsyncTask
Here's a great tutorial to implement these stuff.
Use a DialogFragment, which is a fragment that displays a dialog window, floating on top of its activity's window. This fragment contains a Dialog object, which it displays as appropriate based on the fragment's state. Control of the dialog (deciding when to show, hide, dismiss it) should be done through the API here, not with direct calls on the dialog, so your Activity remains in control.
A Dialog is still part of the same Activity. They just use different windows.
Since you haven't posted any code, I'll answer you theoretically that when building you Dialog, you should keep a reference to the Activity that holds it. This way you would still be able to communicate with it.
I've found a pretty neat work around for this problem. If you place a transparent view on top of everything you can implement a callback to inject an event into the underlying view, but it doesn't have to be an event it can be any code you want to execute on the background view. I have an open source library that demonstrates this. If you check out my repo at: https://bitbucket.org/warwick/hgdialrepo you will find that this library comes with a demo application. Within this demo app you will find a cog demo. If you examine the code behind the cog demo you will see how this can be achieved.

android game pause screen , dialog or activity dialog?

I am a little confused about the best way to show pause screen on my android game. will it be better to be a pauseMenuActivity or is it enough with just pauseDialog? this pause dialog will just show score, money, back button, option button , and quit button. if it is better to show dialog, I don't know how to show those buttons and background image.. anyone can help me? thank you
I would recommend going for a Dialog (or some other custom overlay). From my experience, inter-Activities transitions aren't always very quick and they can feel kind of sluggish in the context of a game. In my opinion, when I am on a pause screen and want to start playing again, it should be instantaneous.
Plus, an Activity is kind of overkill if you just want to show 4 buttons.
To create a custom dialog containing a custom layout, have a look at the following tutorial and post again if you have specific questions/problems :
http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog
An Activity in general is better than a dialog, because u can take care of all things like orientation, theme etc. and it provides more flexibility. Though in simple cases u can use a dialog.

Categories

Resources