android-alertdialog

Can't get an AlertDialog to work

我是研究僧i 提交于 2019-12-25 08:36:39
问题 I have an onLongClickListener that resets some values when called. I would like to ad an alertDialog to check if the user really does want to reset all the values. However I am having no joy making it work. The reset section works fine on it's own but if I try to add the AlertDialog I get the following error: Multiple markers at this line - The constructor AlertDialog.Builder(new View.OnLongClickListener(){}) is undefined - Line breakpoint:SatFinder [line: 174] - onLongClick(View) What

Why is my custom alert dialog code crashing?

吃可爱长大的小学妹 提交于 2019-12-25 07:47:52
问题 I'm trying to apply custom view to alert dialog. I'm doing like this, but there is nullpointer exception when I try to show the alert box. I create a layout.xml like so: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/themescreen" android:gravity="center" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" > <TableLayout android:padding="45dip" android:layout_width="wrap_content" android:layout

How to show alert dialog when hardware Home button is pressed?

岁酱吖の 提交于 2019-12-25 06:55:31
问题 I had used the following code to show an alert dialog when Hardware home button is pressed. @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_HOME)) { System.out.println("KEYCODE_HOME"); showDialog("'HOME'"); return true; } if ((keyCode == KeyEvent.KEYCODE_BACK)) { System.out.println("KEYCODE_BACK"); showDialog("'BACK'"); return true; } if ((keyCode == KeyEvent.KEYCODE_MENU)) { System.out.println("KEYCODE_MENU"); showDialog("'MENU'"); return

How to make selected checkbox item?

一世执手 提交于 2019-12-25 06:48:07
问题 I am getting response from server,and I use textview,and on textview's click listener I set alertdialog,where user can select multiple items,but when values from server via reponse,items are not selected see images below public class ButtonClickHandler implements View.OnClickListener { public void onClick(View view) { showDialog(0); } } @Override protected Dialog onCreateDialog(int id) { return new AlertDialog.Builder(this) .setTitle("Languages") .setMultiChoiceItems(_options, _selections,

Persist AlertDialog options

妖精的绣舞 提交于 2019-12-25 06:38:12
问题 I'm creating an AlertDialog . Here's the snippet of code that I'm using: final CharSequence[] items = {"Red", "Green", "Blue"}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Pick a color"); builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show(); } }); AlertDialog alert = builder.create(); alert.show();

Display string with bold letters in Dialog message

岁酱吖の 提交于 2019-12-25 04:49:10
问题 Let's say I had this: AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()) .setMessage("I want THIS word to be bold and the rest normal!") .create().show(); Is there any way to have Android apply formatting or bold font to parts of the text string? 回答1: You can add a string to your strings.xml like this: <string name="bold_message">I want <b>THIS</b> word to be bold and the rest normal!</string> and then in your alert dialog just use setMessage(R.string.bold_message) 回答2:

Validation for Alert dialog

你离开我真会死。 提交于 2019-12-25 04:45:32
问题 Hi Everyone, Im working in a game and when the player finished the level , Im asking the Player to enter his name on EditText in Alert Dialog : AlertDialog.Builder builder = new Builder(this); LayoutInflater inflater = getLayoutInflater(); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout builder.setView(inflater.inflate(R.layout.dialog_name, null)) // Add action buttons .setPositiveButton(R.string.alertName, new

Calling an alert dialog from another class

不想你离开。 提交于 2019-12-25 04:33:29
问题 I am trying to call an alert dialog from another class but this is not letting me set it to static. It shows as only final is permitted and that means it cannot call it from the other class. I'm not sure if I am doing it correctly or if it is even possible. I have the alert dialog in class 2: static final AlertDialog.Builder alertbox = new AlertDialog.Builder(this); alertDialog = new AlertDialog.Builder(this).create(); alertbox.setTitle("Hello"); alertbox.setMessage("Press Continue or Cancel"

Android: AlertDialog - how to disable certain choices that are not available

拈花ヽ惹草 提交于 2019-12-25 04:07:50
问题 I have AlertDialog that lets user to pick up one of available choices. I have 7 choices and have separate array where 1 and 0 describe whether choice is valid or not. Then I do this : public void createListAlertDialog() { ListView list; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Pick a Sampling Rate"); builder.setSingleChoiceItems(SampleRates_Items, SampleRates_Index, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int

Show one progress dialog only at a time in android?

徘徊边缘 提交于 2019-12-25 03:04:52
问题 I wonder android support multiple dialog? Since when I first open the dialog. I allow user to click cancel, that will open one more dialog to confirm whether the user want to exit , the problem is if the user do not want to exit, the original dialog will disappear, how to fix the problem? Thanks public static ProgressDialog showProgressDialog(final Context ctx, boolean isCancelable) { ProgressDialog dialog = new ProgressDialog(ctx); dialog.setCancelable(false); dialog.setTitle(ctx