How can I change default dialog button text color in android 5

I have many alert dialogs in my app. It is a default layout but I am adding positive and negative buttons to the dialog. So the buttons get the default text color of Android 5 (green). I tried to changed it without success. Any idea how to change that text color? My Custom dialog: public … Read more

How to display a Yes/No dialog box on Android?

Yes, I know there’s AlertDialog.Builder, but I’m shocked to know how difficult (well, at least not programmer-friendly) to display a dialog in Android. I used to be a .NET developer, and I’m wondering is there any Android-equivalent of the following? if (MessageBox.Show(“Sure?”, “”, MessageBoxButtons.YesNo) == DialogResult.Yes){ // Do something… } 17 Answers 17

Dialog throwing “Unable to add window — token null is not for an application” with getApplication() as context

My Activity is trying to create an AlertDialog which requires a Context as a parameter. This works as expected if I use: AlertDialog.Builder builder = new AlertDialog.Builder(this); However, I am leery of using “this” as a context due to the potential for memory leaks when Activity is destroyed and recreated even during something simple like … Read more

How to prevent a dialog from closing when a button is clicked

I have a dialog with EditText for input. When I click the “yes” button on dialog, it will validate the input and then close the dialog. However, if the input is wrong, I want to remain in the same dialog. Every time no matter what the input is, the dialog should be automatically closed when … Read more