android-alertdialog

how to use alertdialog

淺唱寂寞╮ 提交于 2020-01-16 16:26:15
问题 package com.progme.wallkon; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageView; public class NextActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.next); ImageView im1;

Displaying a custom AlertDialog in Android while catching an Exception

本小妞迷上赌 提交于 2020-01-15 18:46:12
问题 I'm trying to display an alert message for the users in a catch block. The difference is that my try/catch is inside the onCreate() from the main activity, so it's executed as soon as the application is opened. I've tried this (I have an OnClick() for Dialogs in the end of the Activity with dialog.dismiss() and this.finish() after): catch (SQLException e) { AlertDialog.Builder builder = new AlertDialog.Builder(this) .setTitle(getString(R.string.label_title_error)) .setIcon(R.drawable.error

how to put values of edit texts in the dialogue box

时光怂恿深爱的人放手 提交于 2020-01-15 10:12:19
问题 I want to give the output, which was entered by the user in EditText, in a detailed manner in a separate dialog box, by using the values of those entered values in the edittext. Any help will be appreciated. Here is the code: EditText editText1,editText2,editText3; Button btn,btn2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btn = (Button) findViewById(R.id.btn); btn2 = (Button) findViewById(R.id

How to implement a Slider within an AlertDialog in Flutter?

被刻印的时光 ゝ 提交于 2020-01-15 01:58:11
问题 I am learning app development on Flutter and can't get my Slider to work within the AlertDialog. It won't change it's value. I did search the problem and came across this post on StackOverFlow: Flutter - Why slider doesn't update in AlertDialog? I read it and have kind of understood it. The accepted answer says that: The problem is, dialogs are not built inside build method. They are on a different widget tree. So when the dialog creator updates, the dialog won't. However I am not able to

Launch AlertDialog not from an Activity

僤鯓⒐⒋嵵緔 提交于 2020-01-14 04:14:13
问题 I am trying to launch an alert dialog when not in a class that extends activity, but I am on the GUI thread. I have access to my applications context and attempt to launch the alert dialog with that but get an error: 02-12 00:48:07.412: ERROR/AndroidRuntime(1322): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application Does anybody know what I am doing wrong on this one? 回答1: You cannot launch a dialog except via an activity, sorry. You are

how to add buttons dynamically in Alert Box in Android

佐手、 提交于 2020-01-14 03:29:07
问题 I am developing android application in which for validations, it displays messages with alert box. I wanted to add buttons dynamically according to certain conditions. I like ask how to do this? I searched on Google, but couldn't find any suitable solutions. Any Suggestions are helpful. Thanks. 回答1: You can use a DialogFragment to acheive it. Create your own dialog view and inflate it in the onCreateView() of the dialog fragment. 回答2: if you know the possible buttons that could be displayed:

finish activity from non activity

痞子三分冷 提交于 2020-01-13 10:01:14
问题 I am developing an app. I want to call a alert dialog from 1st activity. The alert dialog is written in another class which is a non activity class. The need of application is that the calling activity should finish from alert which is written in non activity class. The code of calling the alert is as below. Calling the alert from 1st activity: public class Activity1 extends Activity { /** Called when the activity is first created. */ @Override protected void onCreate(Bundle

How to align custom dialog centre in android ?

喜夏-厌秋 提交于 2020-01-13 09:37:33
问题 I am working on the application where i wanted to display the dialog to be screen size. So i used code below.I got the solution through here Alert message is not displaying in alert dialog box? AlertDialog.Builder builder = new AlertDialog.Builder(this); TextView title = new TextView(this); title.setText("DM2"); title.setBackgroundColor(Color.DKGRAY); title.setPadding(10, 10, 10, 10); title.setGravity(Gravity.CENTER); title.setTextColor(Color.WHITE); title.setTextSize(20); TextView text = new

Keyevent to click on Alert Dialog of Android screen

∥☆過路亽.° 提交于 2020-01-12 10:19:54
问题 Is there any way to simulate keyevent on "OK" or "CANCEL" buttons of Android dialogue box using adb commands? 回答1: One indirect way is:- adb shell uiautomator dump /data/view.xml adb shell cat /data/view.xml calculate OK button coordinates from the relative coordinates given in the xml file. Then do adb shell input tap <x> <y> Hope works. 回答2: Using AndroidViewClient/culebra you can simply do: run java -jar androidviewclient-2.3.25.jar culebra --verbose --verbose-comments --find-views-with

Android EditText in AlertDialog seems too wide

风流意气都作罢 提交于 2020-01-12 06:51:05
问题 It seems like the EditText in the image below is too wide. I assume that I have misused the SDK in some way and until convinced otherwise I am not looking for a way to specify some number of margin/padding pixels on the sides of the EditText . This one looks more appropriate. Here's my code (that creates the first, 'Create Tag', dialog): final Dao<Tag, Integer> tagDao = getHelper().getTagDao(); final EditText input = new EditText(this); input.setSingleLine(true); input.setHint(R.string.create