Questions tagged [android-alertdialog]

A subclass of Dialog that can display one, two or three buttons. If you only want to display a String in this dialog box, use the setMessage() method.

A subclass of Dialog that can display one, two or three buttons. If you only want to display a String in this dialog box, use the setMessage() method. If you want to display a more complex view, look up the FrameLayout called "custom" and add your view to it:

FrameLayout fl = (FrameLayout) findViewById(android.R.id.custom);
fl.addView(myView, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));

The AlertDialog class takes care of automatically setting WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM for you based on whether any views in the dialog return true from View.onCheckIsTextEditor(). Generally you want this set for a Dialog without text editors, so that it will be placed on top of the current input method UI. You can modify this behavior by forcing the flag to your desired mode after calling onCreate(Bundle)

Reference

5697 questions
24
votes
11 answers

getActivity() where it is defined?

I'm very new to android and I'm following this example. The code says we need to do these steps to get an dialog box: AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); // 2. Chain together various setter methods to set the…
sriram
  • 8,562
  • 19
  • 63
  • 82
24
votes
2 answers

DialogFragment : Using AlertDialog with custom layout

I'm rewriting my application with Fragments API support. In the original application I have an AlertDialog that is created like this : LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view =…
Binoy Babu
  • 16,699
  • 17
  • 91
  • 134
23
votes
4 answers

How to make an Alert dialog in full screen in Android?

How to make an Alert Dialog in full screen in Android?
user6629610
  • 241
  • 1
  • 2
  • 3
23
votes
11 answers

How to remove Alert dialog Title bar

I am following this code to create custom dialog but i am not getting how to remove dialog title bar ? AlertDialog alertDialog; @Override protected Dialog onCreateDialog(int id) { AlertDialog dialogDetails = null; switch (id)…
Sun
  • 6,768
  • 25
  • 76
  • 131
23
votes
2 answers

How to get button clicks in host fragment from dialog fragment

I have a listFragment, where I want to display a DialogFragment (Yes/No) on listItemClick. I want to get back the user selection(Yes/No) in listFragment. I have read about the listener interface mechanism but that work with activity<->fragment. One…
SohailAziz
  • 8,034
  • 6
  • 41
  • 43
22
votes
7 answers

Right justify text in AlertDialog

Is it possible to right-justify the text in an AlertDialog's title and message? I am showing Hebrew messages but they are showing up left justified.
theblitz
  • 6,683
  • 16
  • 60
  • 114
22
votes
4 answers

Android Kotlin findViewById must not be null

We have created a custom alert dialog that was used in a Java project by converting it to Kotlin The error posted below java.lang.IllegalStateException: findViewById(R.id.btnYES) must not be null The error source is eluding us ! We have looked at a…
Vector
  • 3,066
  • 5
  • 27
  • 54
22
votes
3 answers

Resources$NotFoundException: Resource ID #0x0 in AlertDialog

I have a RecyclerView, and in its adapter, I have created something similar to an OnLongClickListener, which I am calling an OnEntryLongClickListener to avoid confusion. I am using an AlertDialog to display a dialog with list items for different…
Farbod Salamat-Zadeh
  • 19,687
  • 20
  • 75
  • 125
22
votes
2 answers

Get value from DialogFragment

I want the DialogFragment to return a value to me that was entered in editQuantity when dismissed. But i am not getting any way to make it work. I can do this by passing the value through the intent but that destroys the progress of the current…
Homam
  • 5,018
  • 4
  • 36
  • 39
22
votes
8 answers

How can I set the order of the positive and negative buttons in AlertDialog?

Why I want to do this is another discussion entirely, but I need to figure out the best way to make all my alert dialogs have the positive button on the right side. Note that in version 3.0 and below the buttons normally appear as OK / Cancel and…
Micah Hainline
  • 14,367
  • 9
  • 52
  • 85
21
votes
7 answers

Show AlertDialog with ImageView without any padding

EDIT - SOLUTION: I ended up figuring out a way to solve this issue. Because manually changing the height of the ImageView removes the extra padding, I ended up finding the dimensions of the original image, and apply them to the ImageView once the…
AggieDev
  • 5,015
  • 9
  • 26
  • 48
21
votes
5 answers

How to check if AlertDialog.builder is showing and cancelling it if its showing?

Here is my code - View layout = LayoutInflater.from(this).inflate(R.layout.dialog_loc_info, null); final Button mButton_Mobile = (Button) layout.findViewById(R.id.button); AlertDialog.Builder builder = new…
Darpan
  • 5,623
  • 3
  • 48
  • 80
21
votes
3 answers

AlertDialog setCustomTitle styling to match standard AlertDialog title

I'm working on an Android app and I have an AlertDialog subclass. I would like to put 2 ImageButtons on the right side of the title area of the dialog (similar to an the ActionBar in an Activity). I'm using setCustomTitle() to do this, which…
mikejonesguy
  • 9,779
  • 2
  • 35
  • 49
20
votes
4 answers

How to change the style of a ListPreference popup dialog?

I am trying to change the style of the popup dialog of a ListPreference like I saw in this answer. For example I want a different background colour for the dialog. So far I tried to apply my custom style with:
IIIIIIIIIIIIIIIIIIIIII
  • 3,958
  • 5
  • 45
  • 70
20
votes
3 answers

How to remove AlertDialog programmatically

In an android application, I'm showing to the user an AlertDialog with no buttons, just a message. How can I destroy the AlertDialog programmatically so that it's not visible anymore? I tried with cancel() and dismiss() but they are not working, the…
Nadir
  • 499
  • 1
  • 8
  • 21