android-alertdialog

How can I reuse an AlertDialog for Yes/No on Android?

◇◆丶佛笑我妖孽 提交于 2020-01-12 02:27:46
问题 I'm trying to find the way to reuse a Dialog that shows customized titles, then send the Yes/No click to the function that has launched the Dialog. I have two buttoms, Save and Dismiss, and both call a Yes/No Dialog, one showing "Do you want to save" and the other "Dismiss changes?". I think my procedure is very "dirty" but I guess it can work, but my problem is the "View view" variable, I don't know how to pass it from the Activity to the Dialog, so I can use it to recall the function that

Want to display AlertDialog in onCreate of Activity - android

ぃ、小莉子 提交于 2020-01-11 07:45:09
问题 In my activity, I call a MyDialog (custom dialog) in onCreate() and handle its DismissListener in Activity to find if its cancelled or not. If its cancelled, I finish the activity, else load the activty. During this loading time, I want to show a Alert/Progress dialog to let the user know that its loading, please wait. But am not able to see the dialog. This is how I have coded : public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ld = new AgreeDialog(this);

How to prevent AlertDialog to close?

假如想象 提交于 2020-01-10 04:08:21
问题 I'm using AlertDialog.Builder to build my dialog, it has an EditText which is necessary to be filled and I want to prevent closing the dialog while it is not. In the positive button's onClickListener I can check if the editText is filled or not but I don't know how to prevent closing... builder.setPositiveButton("title", new DialogInterface.OnClickListener(){ @Override public void onClick(DialogInterface dialog, int which) { if(...){ //can close }else{ //prevent closing } } }) 回答1: You can

Android - change dialog title style of all dialogs in application

自古美人都是妖i 提交于 2020-01-09 10:38:26
问题 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 title font color and size of all the dialogs in my app. Is there a way to do it? I have tried setting android:alertDialogTheme in my theme. But it seems to be not working. Code following - <style name="Theme.DLight" parent="android:Theme.Light

Android Alert dialog from inside an intent service

蓝咒 提交于 2020-01-09 05:08:05
问题 I want to display an alert dialog from inside an intent service. AlertDialog alertDialog = new AlertDialog.Builder(this).create(); This throws the following exception Unable to add window — token null is not for an application I have tried IntentService.this and getApplicationContext() as well. Between i dont want to do it using an activity. I just want to show a simple alert dialog with a little text. 回答1: Need Activity for display AlertDialog , because we can't display Dialog from any

How to put an image in an AlertDialog? Android

℡╲_俬逩灬. 提交于 2020-01-09 02:15:05
问题 I don't know how to put an image into an AlertDialog. I have this code, but i think this is not possible. AlertDialog.Builder alert = new AlertDialog.Builder(MessageDemo.this); ImageView imageView = (ImageView) findViewById(R.id.imageView1); imageView.setImageResource(R.drawable.cw); alert.setView(imageView); alert.setNeutralButton("Here!", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sumthin) { } }); alert.show(); 回答1: Create one sample.xml and add

Can't show AlertDialog in DoInBackground

和自甴很熟 提交于 2020-01-07 09:58:06
问题 I am trying to use a AlertDialog in Android which will notify the users that they are runing in offline mode after checking the internet connection. I have used the following codes: protected Void doInBackground(Void... params) { if (this.isOnline()) { new GetJson().execute(); } else { AlertDialog.Builder builder1 = new AlertDialog.Builder(homeFragment); builder1.setMessage("INTERNET CONNECTION NOT AVAILABLE. Now you are viewing the news in Offline Mode."); builder1.setCancelable(true);

Display alert dialog while running an Android test case

混江龙づ霸主 提交于 2020-01-07 02:33:07
问题 I am using Robotium to automate testing of an application. Is there a way I can display an alert box while executing a particular test case. Thanks. 回答1: It is possible to do, nearly everything is possible but before I give you the answer do you have a good reason to do this? I cant easily thing of a good reason why a test should open an alert box but you may know best. Robotium has the method. solo.getCurrentActivity(); Using this you can get an Activity Context and with such a thing you can

Resize AlertDialog to fit image exactly

假装没事ソ 提交于 2020-01-06 19:54:16
问题 I have the following AlertDialog with an image inside it: As you can see there is a small gap just above and just below the image. I'd like to remove that gap. My layout xml looks like: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/alert_thumb_root" android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageView android:id="@+id/thumb" android:layout_width="wrap_content" android:layout

button not shown in alertDialog

浪子不回头ぞ 提交于 2020-01-06 10:41:50
问题 I m creating a class that extends AlertDialog. and setting layout. But when pop up is called, **1) layout is transparent 2) buttons not visible even after calling setButton ** I don't know what to do with , and no Idea why its happening. My classes are this DateTimeDialog.java public class DateTimeDialog extends AlertDialog{ Date date; String title; DialogInterface.OnClickListener listner; protected DateTimeDialog(Context context, String title, Date date ) { super(context); // TODO Auto