i want to show dialog (not alert dialog) but i don't want dialog show modal.
How to set dialog to show modal or not?
this is my code
Dialog dialog = new Dialog(CategoryList.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(actionview);
dialog.show()
you can use PopupWindow instead, and setOutsideTouchable(true).
or try this
Related
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
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.
My problem is when dialog box is showing at that time may i click outside the dialog box, at that time my dialog box is dismissed automatically. What can i do. Please send answers with code. Thanks.
Hi this line is used to dismiss dialog Box.
dialog.setCanceledOnTouchOutside(true);
This line is is used for does not dismiss dialog Box.
dialog.setCanceledOnTouchOutside(false);
The following code will produce a truely model dialog box, with close button. Truely model means, when you click on the area other than dialog box, the dialog box will remain active and will not close.
AlertDialog alert = builder
.setCancelable(false)
.setPositiveButton(context.getResources().getString(R.string.about_close), null)
.create();
alert.show();
The following will produce a dialog box without close button. When you click on the area other than dialog box, the dialog box will be closed.
AlertDialog alert = builder
.setCancelable(false)
.create();
alert.show();
Is there any way I can have a truely model dialog, without button?
dialog.setCanceledOnTouchOutside(false);
I think it is better to make a custom alert-dialogbox. For more help check this
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")