How to create a PopupWindow with images? - android

I'm trying to create a popup window similar to programmatically. Unfortunately I couldn't figure out any helpful resource so far for creating a similar popup.

You can do it with Dialog
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.chat_custom_dialog);
dialog.setTitle("custom dialog");
dialog.show();
where dialog.setContentView(R.layout.chat_custom_dialog); will set the layout of the dialog.
And if you want to update the dialog's layout views you can call the dialog.findViewById(id) to get the view inside of the layout same as what you are doing in the activity

Related

Handling textview hit bottom in alert dialog

I'm setting a message in a simple alert dialog. I need to know if the user has read all the text inside the dialog or not. Is there any way to set a scroll listener or something in an alert dialog?
Create your custom dialog and then set some listener to your custom View. Here's a good example: http://www.mkyong.com/android/android-custom-dialog-example/
and
https://stackoverflow.com/a/10713501

Is it possible to set positive and negative buttons in a Dialog?

I have a Dialog in my android app and I want to set positive/negative buttons in the dialog. It is a Dialog, not an AlertDialog. I know that I could actually use an AlertDialog, but I would like to know, whether the same is possible within a dialog. If there is a possibility, I appreciate all of you for an example.
you can add anything you want in dialog. For an example
dialog = new Dialog(this);
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("Custom Dialog");
Button dialog_btn = (Button) dialog.findViewById(R.id.dialog_button);
dialog_btn.setOnClickListener(new View.OnClickListener()
{
// TODO:
}
Here custom_dialog is a custom layout for dialog which has a button dialog_button. similarly you can add any widget and handle that.

display a view when an activity starts

I need to display a certain view when an activity starts, and when the user click ckecked to dismiss the view. It look like this
:
Has anyone an idea how can I do this? Any idea is welcome.
Yes, you can use a custom dialog
just create a custom XML and inflate it into your dialog object
Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.custom_dialog);
dialog.show();
and then dismiss it by calling dialog.dismiss();
create custom dialog using below link and open it when activity starts...
you need to increase the margin to proivde more spaces
Have a look at custom dialog examples -
custom dialog 1
custom dialog 2
yes, you can use PopupWindow for Creating window
see these tutorila for adding PopupWindow in your Activity:
Using the PopupWindow class in Android apps
Example of using PopupWindow
You could use a RelativeLayout for this. When the user clicks check, the visibility of the 'upper' layout must be set to GONE.

How To Get A Pop Up Layout?

How can I have a pop-up window, with a new layout, but with the old layout in the background?
Also I'd like to have a button on the first layout call the second layout based on an if-statement, using something like this
"if Button has a background, button open new layout, if not null"
You could use a Dialog to create the pop-up. For example, in your activity onCreate() method set up a new dialog and specify the layout using XML like normal.
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.--);
then simply call dialog.show() when you want to show the pop-up.

Transparent Alert Dialog box

I have few doubts regarding transparent AlertDialog box in android.I have created the alert dialog box using AlertDialog.builder in the camera surface view but i want Transparent alert dialog box is it possible. please help me
Regards
Raj
Use this
The code is as follows
Dialog mDialog = new Dialog(mContext, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
Answer taken from a similar answer here
Yes, this is possible. I believe you can do it by creating a custom alert dialog:
http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog
you can then set the background of your custom dialog to transparent like so:
this.getWindow().setBackgroundDrawableResource(R.drawable.transparent);
(where "R.drawable.transparent" is a reference to the color "#00000000")

Categories

Resources