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
19
votes
6 answers

AlertDialog setOnDismissListener not working

My activity opens a dialog. When it closes I need the function ReloadTable() to be executed. So I am trying to use setOnDismissListener but its not getting triggered. Could someone please help what I am doing wrong? Thanks! AlertDialog.Builder…
lumpawire
  • 468
  • 1
  • 7
  • 16
18
votes
4 answers

showDialog bug: dialog isn't triggered from PopupMenuButton in Flutter

I am not able to get showDialog work with PopupMenuButton. In the example below, there is a button with triggering a dialog to display and a popupmenu too triggering a dialog to display. The button works but on clicking on the Alert text in…
kamalbanga
  • 1,881
  • 5
  • 27
  • 46
18
votes
4 answers

In Android Navigation Architecture, how can I check if current Fragment is the last one?

I need to display custom AlertDialog, but only when there are no more fragments after calling NavController.navigateUp(). My current code does something similar, but there is a bug to it: override fun onBackPressed() { if…
18
votes
1 answer

Crosswalk Cordova - js alert shows block characters on Chinese interface android

I have a Phonegap Android app with barcode reader which I migrated to Crosswalk using the beta version, and now my alert dialog shows strange blocks instead of latin characters, as shown in the screenshot below. This should show the following text…
Daniel Cheung
  • 4,779
  • 1
  • 30
  • 63
18
votes
4 answers

android AlertDialog setView rules

The setView() method of the AlertDialog class allows one to specify a custom view for the dialog box. Are there any restrictions as to what controls can be included in this custom view ? Also, if we set a custom view, can we still add buttons using…
Cygnus
  • 3,222
  • 9
  • 35
  • 65
18
votes
1 answer

Dark text on dark background on AlertDialog with Theme.Sherlock.Light

I'm using Theme.Sherlock.Light theme for my application and I'm creating a DialogFragment with an underlying AlertDialog. It works just fine on Android 3.x and 4.x, but on Android 2.x I see dark text on dark background, which is hardly readable. Am…
Egor
  • 39,695
  • 10
  • 113
  • 130
17
votes
2 answers

how to include custom title view with in AlertDialog in android?

how can i include custom titlebar in alertDialog?I know android sdk provide setCustomTitle method but it does'not work edit: AlertDialog alert = new AlertDialog.Builder(this).setTitle("Test").setMessage("hello").show(); View…
sAaNu
  • 1,428
  • 7
  • 21
  • 46
17
votes
1 answer

Custom objects in AlertDialog list; how to get a display string and then the actual value?

I have been looking at Android AlertDialog, and its easy enough to use the setItems(...) to add a list of Strings that are to be shown. However, in most cases you want a list showing nice Strings, but when selecting something from the list you want…
Ted
  • 19,727
  • 35
  • 96
  • 154
17
votes
1 answer

Is there a way prevent AlertDialog from closing with invalid inputs?

I am using a simple text field alert dialog with a positive and a cancel button. I want to validate my alert dialog and prevent the done button from closing the AlertDialog if the input is invalid. Is there any way short of creating a custom dialog…
Jeff Axelrod
  • 27,676
  • 31
  • 147
  • 246
17
votes
4 answers

Can't get Android DatePickerDialog to switch to Spinner mode

I am building an app that uses a DatePickerDialog to allow the user to select their birthdate. Here's the code that loads the dialog right now: private void selectBirthdate() { int year, month, day; if (mBirthDate == null) { year =…
17
votes
2 answers

How do I call findViewById on an AlertDialog.Builder?

I'm trying to get a reference to a TextView in the AlertDialog with this code: AlertDialog.Builder logoutBuilder = new AlertDialog.Builder(getActivity()); TextView alertTextView = (TextView)…
Lv99Zubat
  • 853
  • 2
  • 10
  • 27
17
votes
4 answers

Hiding Status Bar while showing Alert Dialog Android

I'm making an app where an alert dialog pops up when you hit a certain button. The status bar needs to be hidden, so I have a method in my activity: private void hideStatusBar(){ if (Build.VERSION.SDK_INT < 16){ …
Thomas
  • 1,123
  • 3
  • 13
  • 36
16
votes
5 answers

Copy text from Android AlertDialog?

Is there any way to make the text in an AlertDialog "selectable" or "copyable" in Android? Or do I have to use some other widget instead of AlertDialog?
javamonkey79
  • 17,443
  • 36
  • 114
  • 172
16
votes
4 answers

Android: AlertDialog causes a memory leak

My application shows an AlertDialog with a ListView inside. Everything worked fine bun then I decided to test this for memory leaks. After running the app for some time I opened MAT and generated Leak Suspects report. MAT found several similar…
Michael
  • 53,859
  • 22
  • 133
  • 139
16
votes
3 answers

Show soft keyboard in AlertDialog with a WebView inside (Android)

In my Android app I create an AlertDialog that has a WebView inside. The WebView loads a webpage that requires the user to log in. However, when I click on text fields in the WebView, soft keyboard does not appear. I am aware of the issue in general…
user519908