Android Pop up window - android

I looked online and was not able to find a working example of the PopupWindow class. The code examples I found online either compile but do not work, or are using methods which have since been removed (such as Activity.getViewInflate()).
Is there a simple working example that displays a PopupWindow?

Any Activity can be a "popup window" it just has to show up on top of the previous activity and not take up all the screen real estate! :)
Here's an example of how this works...
How do I create a transparent Activity on Android?
Or are you just looking for an Alert that gets dismissed by being touched anywhere (rather than with an "OK" button?

May be AlertDialog can solve your problem you can full screen dialog window it just look like a window it is an alternative

Related

How to add pop up option screen at start of app? Android studio

I'm looking to have a window pop up at the very start of my android app with two options on it.
I have two functional buttons already in my app and I'd like the user to pick one of the two buttons before they get in to the app.
Lets say the screen pops up at launch and I'd like it to say "Please choose either 'button1' or 'button2'"
I've found a few solutions but none that I can actually get working...think that might be might novice status though.
Thanks for any help.
You should create a splash screen (many tutorials can be found on this, here is an example). After having this activity, you can create a Dialog with 2 buttons (example here).
You can set a positive and negative button on the dialog to do this, and also use a callback for the click behavior (example here).

How to show a pop up in Android and still be able to click on fragment

I'm trying to create a pop up that will notify the user if they got the correct answer, the user can then click the continue button to the next question. The pic below from the Duolingo app shows exactly what I want.
What class can be used to do this?
Use the PopupWindow class. It does exactly what you want. That's what has been used in the screenshot you posted above.
Here's an example: How to Implement Popup Window in Android.

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.

Popup window using Fragment

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

Categories

Resources