List of usage examples for android.app AlertDialog setButton
@Deprecated public void setButton(CharSequence text, final OnClickListener listener)
From source file:com.tweetlanes.android.view.BaseLaneActivity.java
public void shareSelected(TwitterStatus status) { if (status != null) { final String statusUrl = status.getTwitterComStatusUrl(); final String statusText = status.mStatus; final ArrayList<String> urls = Util.getUrlsInString(status.mStatus); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(getString(R.string.alert_share_title)); alertDialog.setMessage(getString(R.string.alert_share_message)); alertDialog.setIcon(AppSettings.get().getCurrentTheme() == AppSettings.Theme.Holo_Dark ? R.drawable.ic_action_share_dark : R.drawable.ic_action_share_light); // TODO: The order these buttons are set looks wrong, but appears correctly. Have to ensure this is consistent on other devices. alertDialog.setButton2(getString(R.string.share_tweet_link), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { shareText(statusUrl);/*from w ww. j a v a 2 s .co m*/ } }); if (urls != null && urls.size() > 0) { alertDialog.setButton3(getString(R.string.share_tweet), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { shareText(statusText); } }); alertDialog.setButton(getString(urls.size() == 1 ? R.string.share_link : R.string.share_first_link), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { shareText(urls.get(0)); } }); } else { alertDialog.setButton(getString(R.string.share_tweet), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { shareText(statusText); } }); } alertDialog.show(); } }
From source file:foam.littlej.android.app.ui.phone.AddReportActivity.java
/** * Create various dialog/*w ww . j a v a 2 s .c o m*/ */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ERROR_NETWORK: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.network_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_ERROR_SAVING: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.file_system_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_CHOOSE_IMAGE_METHOD: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.choose_method)); dialog.setMessage(getString(R.string.how_to_select_pic)); dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_IMAGE); dialog.dismiss(); } }); dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, PhotoUtils.getPhotoUri(photoName, AddReportActivity.this)); startActivityForResult(intent, REQUEST_CODE_CAMERA); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_MULTIPLE_CATEGORY: { if (showCategories() != null) { return new AlertDialog.Builder(this).setTitle(R.string.choose_categories) .setMultiChoiceItems(showCategories(), setCheckedCategories(), new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { // see if categories have previously if (isChecked) { mVectorCategories.add(mCategoriesId.get(whichButton)); mError = false; } else { mVectorCategories.remove(mCategoriesId.get(whichButton)); } setSelectedCategories(mVectorCategories); } }) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked Yes so do some stuff */ } }).create(); } } case TIME_DIALOG_ID: return new TimePickerDialog(this, mTimeSetListener, mCalendar.get(Calendar.HOUR), mCalendar.get(Calendar.MINUTE), false); case DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH)); case DIALOG_SHOW_MESSAGE: AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this); messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showDialog = messageBuilder.create(); showDialog.show(); break; case DIALOG_SHOW_REQUIRED: AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this); requiredBuilder.setTitle(R.string.required_fields); requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showRequiredDialog = requiredBuilder.create(); showRequiredDialog.show(); break; // prompt for unsaved changes case DIALOG_SHOW_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.unsaved_changes)); dialog.setMessage(getString(R.string.want_to_cancel)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { new DiscardTask(AddReportActivity.this).execute((String) null); finish(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } // prompt for report deletion case DIALOG_SHOW_DELETE_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.delete_report)); dialog.setMessage(getString(R.string.want_to_delete)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete report deleteReport(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } } return null; }
From source file:com.shafiq.mytwittle.view.BaseLaneActivity.java
public void shareSelected(TwitterStatus status) { if (status != null) { final String statusUrl = status.getTwitterComStatusUrl(); final String statusText = status.mStatus; final ArrayList<String> urls = Util.getUrlsInString(status.mStatus); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(getString(R.string.alert_share_title)); alertDialog.setMessage(getString(R.string.alert_share_message)); alertDialog.setIcon(AppSettings.get().getCurrentTheme() == AppSettings.Theme.Holo_Dark ? R.drawable.ic_action_share_dark : R.drawable.ic_action_share_light); // TODO: The order these buttons are set looks wrong, but appears // correctly. Have to ensure this is consistent on other devices. alertDialog.setButton2(getString(R.string.share_tweet_link), new DialogInterface.OnClickListener() { @Override//from ww w. ja va 2 s. co m public void onClick(DialogInterface dialog, int which) { shareText(statusUrl); } }); if (urls != null && urls.size() > 0) { alertDialog.setButton3(getString(R.string.share_tweet), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { shareText(statusText); } }); alertDialog.setButton(getString(urls.size() == 1 ? R.string.share_link : R.string.share_first_link), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { shareText(urls.get(0)); } }); } else { alertDialog.setButton(getString(R.string.share_tweet), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { shareText(statusText); } }); } alertDialog.show(); } }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public static void UIAlert(String title, String body, Activity activity) { AlertDialog ad; ad = new AlertDialog.Builder(activity).create(); ad.setTitle(title);//from w w w.j ava 2 s . c om ad.setMessage(body); ad.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); ad.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public static void UIAlertHtml(String title, String html, Activity activity) { AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle(title);//from w w w . j a va 2 s .co m WebView webview = new WebView(activity); webview.setBackgroundColor(Color.BLACK); webview.loadData("<font color=\"FFFFFF\">" + html + " </font>", "text/html", "UTF-8"); alertDialog.setView(webview); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); alertDialog.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public static void UIAlertLicense(String title, String html, final Activity activity) { AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle(title);/*from ww w. j av a2s .c o m*/ WebView webview = new WebView(activity); webview.setBackgroundColor(Color.BLACK); webview.loadData("<font color=\"FFFFFF\">" + html + " </font>", "text/html", "UTF-8"); alertDialog.setView(webview); alertDialog.setButton("I Acknowledge", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (isFirstLaunch()) { install(); onHelp(); onChangeLog(); } setFirstLaunch(); return; } }); alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (isFirstLaunch()) { if (activity.getParent() != null) { activity.getParent().finish(); } else { activity.finish(); } } } }); alertDialog.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptMachineName(final Activity activity) { final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Machine Name"); EditText searchView = new EditText(activity); searchView.setEnabled(true);//from w w w .j av a 2 s. co m searchView.setVisibility(View.VISIBLE); searchView.setId(201012010); searchView.setSingleLine(); alertDialog.setView(searchView); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // UIUtils.log("Searching..."); EditText a = (EditText) alertDialog.findViewById(201012010); sendHandlerMessage(handler, Const.VM_CREATED, "machine_name", a.getText().toString()); return; } }); alertDialog.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptStateName(final Activity activity) { final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Snapshot/State Name"); EditText searchView = new EditText(activity); searchView.setEnabled(true);/*from w w w . j a va2 s . c o m*/ searchView.setVisibility(View.VISIBLE); searchView.setId(201012010); searchView.setSingleLine(); alertDialog.setView(searchView); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // UIUtils.log("Searching..."); EditText a = (EditText) alertDialog.findViewById(201012010); sendHandlerMessage(handler, Const.SNAPSHOT_CREATED, new String[] { "snapshot_name" }, new String[] { a.getText().toString() }); return; } }); alertDialog.show(); }
From source file:self.philbrown.droidQuery.$.java
/** * Show an alert//from ww w . j ava 2 s .c om * @param context used to display the alert window * @param title the title of the alert window. Use {@code null} to show no title * @param text the alert message * @see #alert(Context, String) */ public static void alert(Context context, String title, String text) { AlertDialog alert = new AlertDialog.Builder(context).create(); alert.setTitle(title); alert.setMessage(text); alert.setButton("OK", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alert.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
private void promptPrio(final Activity activity) { // TODO Auto-generated method stub final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Enable High Priority!"); TextView textView = new TextView(activity); textView.setVisibility(View.VISIBLE); textView.setId(201012010);//w ww . j av a 2 s.c om textView.setText( "Warning! High Priority might increase emulation speed but " + "will slow your phone down!"); alertDialog.setView(textView); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { LimboSettingsManager.setPrio(activity, true); } }); alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mPrio.setChecked(false); return; } }); alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mPrio.setChecked(false); } }); alertDialog.show(); }