List of usage examples for android.app AlertDialog setButton2
@Deprecated public void setButton2(CharSequence text, final OnClickListener listener)
From source file:foam.littlej.android.app.ui.phone.AddReportActivity.java
/** * Create various dialog//from www . ja va 2s .c om */ @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:cm.aptoide.pt.RemoteInSearch.java
@Override protected void onListItemClick(ListView l, View v, final int position, long id) { super.onListItemClick(l, v, position, id); Vector<String> tmp_get = db.getApk(apk_lst.get(position).apkid); String tmp_path = this.getString(R.string.icons_path) + apk_lst.get(position).apkid; File test_icon = new File(tmp_path); LayoutInflater li = LayoutInflater.from(this); View view = li.inflate(R.layout.alertscroll, null); Builder alrt = new AlertDialog.Builder(this).setView(view); final AlertDialog p = alrt.create(); if (test_icon.exists() && test_icon.length() > 0) { p.setIcon(new BitmapDrawable(tmp_path)); } else {/*from w ww . j a v a 2 s. c om*/ p.setIcon(android.R.drawable.sym_def_app_icon); } p.setTitle(apk_lst.get(position).name); TextView t1 = (TextView) view.findViewById(R.id.n11); t1.setText(tmp_get.firstElement()); TextView t2 = (TextView) view.findViewById(R.id.n22); t2.setText(tmp_get.get(1)); TextView t3 = (TextView) view.findViewById(R.id.n33); t3.setText(tmp_get.get(2)); TextView t4 = (TextView) view.findViewById(R.id.n44); t4.setText(tmp_get.get(3)); TextView t5 = (TextView) view.findViewById(R.id.n55); String tmpi = db.getDescript(apk_lst.get(position).apkid); if (!(tmpi == null)) { t5.setText(tmpi); } else { t5.setText("No info availale on server. Search market by pressing the button below for more info."); } p.setButton2("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); if (tmp_get.get(2).equalsIgnoreCase("\tno\n")) { p.setButton(getString(R.string.install), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { p.dismiss(); new Thread() { public void run() { String apk_pkg = downloadFile(position); if (apk_pkg == null) { Message msg = new Message(); msg.arg1 = 1; download_handler.sendMessage(msg); download_error_handler.sendEmptyMessage(0); } else { installApk(apk_pkg, position); } } }.start(); } }); p.setButton3("Search Market", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { p.dismiss(); Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=" + apk_lst.get(position).apkid)); startActivity(intent); } }); } else { p.setButton(getString(R.string.rem), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String apk_pkg = apk_lst.get(position).apkid; removeApk(apk_pkg, position); } }); if (apk_lst.get(position).status == 2) { p.setButton3(getString(R.string.update), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { p.dismiss(); new Thread() { public void run() { String apk_pkg = downloadFile(position); if (apk_pkg == null) { //Toast.makeText(RemoteInSearch.this, "Could not connect to server!", Toast.LENGTH_LONG).show(); Message msg = new Message(); msg.arg1 = 1; download_handler.sendMessage(msg); download_error_handler.sendEmptyMessage(0); } else { installApk(apk_pkg, position); } } }.start(); } }); } else { p.setButton3("Search Market", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { p.dismiss(); Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=" + apk_lst.get(position).apkid)); startActivity(intent); } }); } } p.show(); }
From source file:cm.aptoide.pt.RemoteInTab.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case UPDATE_REPO: final AlertDialog upd_alrt = new AlertDialog.Builder(this).create(); if (!db.areServers()) { upd_alrt.setIcon(android.R.drawable.ic_dialog_alert); upd_alrt.setTitle("Empty"); upd_alrt.setMessage(/*from ww w . j a va 2 s .co m*/ "There are no enabled repositories in your list.\nPlease add repository or enable the ones you have!"); upd_alrt.setButton("Ok", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); } else { upd_alrt.setIcon(android.R.drawable.ic_dialog_alert); upd_alrt.setTitle("Update repositories"); upd_alrt.setMessage( "Do you wish to update repositories?\nThis can take a while (WiFi is advised)..."); upd_alrt.setButton("Yes", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { updateRepos(); } }); upd_alrt.setButton2("No", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { upd_alrt.dismiss(); } }); } upd_alrt.show(); return true; case MANAGE_REPO: Intent i = new Intent(this, ManageRepo.class); startActivityForResult(i, NEWREPO_FLAG); return true; case SEARCH_MENU: onSearchRequested(); return true; case ABOUT: LayoutInflater li = LayoutInflater.from(this); View view = li.inflate(R.layout.about, null); Builder p = new AlertDialog.Builder(this).setView(view); final AlertDialog alrt = p.create(); alrt.setIcon(R.drawable.icon); alrt.setTitle("APTOIDE"); alrt.setButton("ChangeLog", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Uri uri = Uri.parse("http://aptoide.com/changelog.html"); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } }); alrt.show(); return true; case SETTINGS: Intent s = new Intent(RemoteInTab.this, Settings.class); s.putExtra("order", order_lst); startActivityForResult(s, SETTINGS_FLAG); } return super.onOptionsItemSelected(item); }
From source file:com.glm.trainer.NewMainActivity.java
@Override public void onBackPressed() { AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(this.getString(R.string.titleendapp)); alertDialog.setMessage(this.getString(R.string.messageendapp)); alertDialog.setButton(this.getString(R.string.yes), new android.content.DialogInterface.OnClickListener() { @Override/*from w ww . jav a 2s. c om*/ public void onClick(DialogInterface arg0, int arg1) { if (mConnection != null && mConnection.mIService != null) { try { mConnection.mIService.stopGPSFix(); mConnection.mIService.shutDown(); mConnection.destroy(); } catch (RemoteException e) { // TODO Auto-generated catch block //Log.e(this.getClass().getCanonicalName(),e.getMessage()); } } finish(); } }); alertDialog.setButton2(this.getString(R.string.no), new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { } }); alertDialog.show(); }
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 w w .j a v a 2 s . c om*/ } }); 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: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 w w w . j a v a2 s . c om*/ 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:cm.aptoide.pt.ManageRepo.java
private void editRepo(final String repo) { LayoutInflater li = LayoutInflater.from(this); View view = li.inflate(R.layout.addrepo, null); Builder p = new AlertDialog.Builder(this).setView(view); final AlertDialog alrt = p.create(); final EditText uri = (EditText) view.findViewById(R.id.edit_uri); uri.setText(repo);//from w ww. j av a 2s .com final EditText sec_user = (EditText) view.findViewById(R.id.sec_user); final EditText sec_pwd = (EditText) view.findViewById(R.id.sec_pwd); final CheckBox sec = (CheckBox) view.findViewById(R.id.secure_chk); sec.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { sec_user.setEnabled(true); sec_pwd.setEnabled(true); } else { sec_user.setEnabled(false); sec_pwd.setEnabled(false); } } }); String[] logins = null; logins = db.getLogin(repo); if (logins != null) { sec.setChecked(true); sec_user.setText(logins[0]); sec_pwd.setText(logins[1]); } else { sec.setChecked(false); } alrt.setIcon(android.R.drawable.ic_menu_add); alrt.setTitle("Edit repository"); alrt.setButton("Done", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String new_repo = uri.getText().toString(); db.updateServer(repo, new_repo); if (sec.isChecked()) { db.addLogin(sec_user.getText().toString(), sec_pwd.getText().toString(), new_repo); } else { db.disableLogin(new_repo); } change = true; redraw(); } }); alrt.setButton2("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); alert2.dismiss(); alrt.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);//from www . j av a 2 s .c o m 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(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptMultiAIO(final Activity activity) { // if (!ICS) { // Toast.makeText(getApplicationContext(), // "Multithread AIO supported only for ICS and above!", // Toast.LENGTH_SHORT).show(); // this.mMultiAIO.setChecked(false); // return;// w w w . j a v a 2 s . c om // } final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Warning!"); TextView info = new TextView(activity); info.setText("Enabling Multithreaded AIO might speed up I/O in the VM " + "but it might not work for all devices. " + "Multithreaded AIO is experimental and might damage any disk image you open with Limbo so keep a " + "backup of your images if you're not certain. " + "If you see errors uncheck this option and try again."); alertDialog.setView(info); final Handler handler = this.handler; alertDialog.setButton("Set", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { LimboSettingsManager.setMultiAIO(activity, true); } }); alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mMultiAIO.setChecked(false); LimboSettingsManager.setMultiAIO(activity, false); return; } }); alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mMultiAIO.setChecked(false); LimboSettingsManager.setMultiAIO(activity, false); } }); alertDialog.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
private void promptImportMachines() { // TODO Auto-generated method stub final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Import Machines"); RelativeLayout mLayout = new RelativeLayout(this); mLayout.setId(12222);//from w w w . j ava 2 s . c om TextView imageNameView = new TextView(activity); imageNameView.setVisibility(View.VISIBLE); imageNameView.setId(201012010); imageNameView.setText( "Step 1: Place the machine.CSV file you export previously under \"limbo\" directory in your SD card.\n" + "Step 2: WARNING: Any machine with the same name will be replaced!\n" + "Step 3: Press \"OK\".\n"); RelativeLayout.LayoutParams searchViewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); mLayout.addView(imageNameView, searchViewParams); alertDialog.setView(mLayout); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // For each line create a Machine progDialog = ProgressDialog.show(activity, "Please Wait", "Importing Machines...", true); ImportMachines importer = new ImportMachines(); importer.execute(); } }); alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { return; } }); alertDialog.show(); }