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
16
votes
4 answers

How uncheck items in AlertDialog (setMultiChoiceItems)?

I'd like to clear selected items when the total came to three items selected, I am doing as follows but is not working ... AlertDialog.Builder builder = new…
Eduardo Teixeira
  • 963
  • 1
  • 11
  • 21
16
votes
1 answer

Dismissing a Cupertino dialogue action Flutter

While dismissing a presented Cupertino alert dialogue action using the explained method my entire screen gets popped of and the alert dialogue stays on the screen. This is my code. if (deviceList.isEmpty){ var alert = new…
Chaythanya Nair
  • 4,774
  • 6
  • 32
  • 40
16
votes
3 answers

Set AlertDialog Positive Button Text to be Bold

Here is my code. AlertDialog.Builder builder = new AlertDialog.Builder(this); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View vi = inflater.inflate(R.layout.group_dialog_layout,null); …
user3098538
  • 1,201
  • 3
  • 13
  • 15
16
votes
4 answers

AlertDialog - do not dismiss on item click

OK so I am creating an ArrayAdapter and using it in my Alert Dialog because I don't want to show the default radio buttons on SingleItemSelection dialog. Instead I want to change the background of the item that is selected, and then when the user…
user445338
16
votes
2 answers

Show a dialog in `Thread.setDefaultUncaughtExceptionHandler`

When my android application throw an exception, I want to show a custom dialog to tell user there is something wrong happened, so I use Thread.setDefaultUncaughtExceptionHandler to set a global exception handler: public class MyApplication extends…
Freewind
  • 193,756
  • 157
  • 432
  • 708
16
votes
2 answers

Android - change dialog title style of all dialogs in application

Is there a way I can change all the alert dialogs appearing in my Android application? I want to change the dialogs that are system generated as well (like the Edit Text dialog that opens up when you long tap on any EditText). I want to change the…
jaibatrik
  • 6,770
  • 9
  • 33
  • 62
15
votes
1 answer

Using ArrayAdapter with AlertDialog and .setAdapter

My code goes inside an OnOptionsItemSelected method. I've tried displaying a simple toast and it works fine, so at least I know I'm "getting there". ArrayAdapter adapter = new ArrayAdapter(this,…
HSPalm
  • 165
  • 1
  • 2
  • 8
15
votes
2 answers

AlertDialog inside onClickListener

I'm trying to start an AlertDialog from an onClickListener but I'm getting the following error. The constructor AlertDialog.Builder(new View.OnClickListener(){}) is undefined Does anyone know how to fix this? …
Carnivoris
  • 793
  • 3
  • 7
  • 23
15
votes
3 answers

Window manager bad token exception

Hi I am facing a problem in Message dialog, getting Force close my code is here. in on create: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.email_result); email_result =…
Jignesh Ansodariya
  • 12,583
  • 24
  • 81
  • 113
15
votes
3 answers

Android Custom Alert Dialog Display Error after changing the Build Version

I am developing a simple demo . Here in this demo, I am just creating one simple custom alert dialog . It works fine. It shows me the perfect result when i build application in 1.6, but when i change the android version from 1.6 to 2.2, it shows the…
Chirag
  • 56,621
  • 29
  • 151
  • 198
15
votes
2 answers

How to change MaterialAlertDialog text color properly?

I try to use widgets from Material Components only, but in many cases, it's not documented how styling can be achieved. Let's consider MaterialAlertDialog. Each time I want to show a dialog, I call such part of the…
15
votes
5 answers

Android: dialog box without shadow around it

How do I remove this "shadowBox" effect around the dialog box that fades the background? I know I can create like totally custom view but let's say I want to keep it simple. I have xml layout for dialog with only textView and 2 buttons and I want to…
yosh
  • 3,245
  • 7
  • 55
  • 84
15
votes
2 answers

AlertDialog does not show dividers on a list

I have this class: public class PageDetailInfoView extends FrameLayout { //few constructors and methods //method to show an AlertDialog with a list private void openDialog(){ List mTags = new ArrayList(); …
JoCuTo
  • 2,463
  • 4
  • 28
  • 44
15
votes
2 answers

Disable (positive) button of AlertDialog by Default

How do you disable the positive button of an Android AlertDialog by default? It appears to be quite normal to want the positive button (In this case "Save") to be disabled before the user has made a change to the view (In this case an EditText. I…
Joakim
  • 3,224
  • 3
  • 29
  • 53
15
votes
2 answers

Android: disable DialogFragment OK/Cancel buttons

How can I disable OK/Cancel button of a DialogFragment when it is created using an AlertDialog ? I tried calling myAlertDialogFragment.getDialog() but it's always returning null even once the fragment is displayed public static class…
user1026605
  • 1,633
  • 4
  • 22
  • 58