List of usage examples for android.app AlertDialog.Builder setTitle
@Override public void setTitle(CharSequence title)
From source file:net.granoeste.scaffold.app.ScaffoldAlertDialogFragment.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { int iconId = getArguments().getInt(ICON_ID, 0); String title = getArguments().getString(TITLE); String message = getArguments().getString(MESSAGE); boolean hasPositive = getArguments().getBoolean(HAS_POSITIVE, false); boolean hasNeutral = getArguments().getBoolean(HAS_NEUTRAL, false); boolean hasNegative = getArguments().getBoolean(HAS_NEGATIVE, false); String positiveText = getArguments().getString(POSITIVE_TEXT); String neutralText = getArguments().getString(NEUTRAL_TEXT); String negativeText = getArguments().getString(NEGATIVE_TEXT); boolean cancelable = getArguments().getBoolean(CANCELABLE, true); boolean canceledOnTouchOutside = getArguments().getBoolean(CANCELED_ON_TOUCH_OUTSIDE, false); final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); if (iconId > 0) { builder.setIcon(iconId);/*from w w w.j a va 2 s . c om*/ } if (StringUtils.isNoneEmpty(title)) { builder.setTitle(title); } if (StringUtils.isNoneEmpty(message)) { builder.setMessage(message); } if (hasPositive) { if (StringUtils.isEmpty(positiveText)) { positiveText = getResources().getString(R.string.yes); } builder.setPositiveButton(positiveText, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int whichButton) { synchronized (mOnAlertDialogEventListeners) { for (OnAlertDialogEventListener listener : mOnAlertDialogEventListeners) { listener.onDialogClick(dialog, whichButton, getTag()); } } } }); } if (hasNeutral) { if (StringUtils.isEmpty(neutralText)) { neutralText = getResources().getString(R.string.no); } builder.setNeutralButton(neutralText, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int whichButton) { synchronized (mOnAlertDialogEventListeners) { for (OnAlertDialogEventListener listener : mOnAlertDialogEventListeners) { listener.onDialogClick(dialog, whichButton, getTag()); } } } }); } if (hasNegative) { if (StringUtils.isEmpty(negativeText)) { negativeText = getResources().getString(hasNeutral ? R.string.cancel : R.string.no); } builder.setNegativeButton(negativeText, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int whichButton) { synchronized (mOnAlertDialogEventListeners) { for (OnAlertDialogEventListener listener : mOnAlertDialogEventListeners) { listener.onDialogClick(dialog, whichButton, getTag()); } } } }); } builder.setCancelable(cancelable); if (cancelable) { builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(final DialogInterface dialog) { synchronized (mOnAlertDialogEventListeners) { for (OnAlertDialogEventListener listener : mOnAlertDialogEventListeners) { listener.onDialogCancel(dialog, getTag()); } } } }); } // View customView = getCustomView(); if (mCustomView != null) { builder.setView(mCustomView); } Dialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(canceledOnTouchOutside); return dialog; }
From source file:org.starfishrespect.myconsumption.android.ui.ChartChoiceFragment.java
private void deleteSensor(int index) { AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); builder.setTitle(R.string.dialog_title_confirmation); builder.setMessage(/*from ww w .j av a 2s.c o m*/ String.format(getResources().getString(R.string.dialog_message_confirmation_delete_sensor), sensors.get(lastLongClickItem).getName())); builder.setNegativeButton(R.string.button_no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setPositiveButton(R.string.button_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { new AsyncTask<Void, Boolean, Void>() { @Override protected Void doInBackground(Void... params) { RestTemplate template = new RestTemplate(); HttpHeaders httpHeaders = CryptoUtils.createHeadersCurrentUser(); template.getMessageConverters().add(new FormHttpMessageConverter()); template.getMessageConverters().add(new StringHttpMessageConverter()); String url = SingleInstance.getServerUrl() + "users/" + SingleInstance.getUserController().getUser().getName() + "/sensor/" + sensors.get(lastLongClickItem).getSensorId(); template.exchange(url, HttpMethod.DELETE, new HttpEntity<>(httpHeaders), String.class); try { SingleInstance.getDatabaseHelper().getSensorDao() .delete(sensors.get(lastLongClickItem)); new SensorValuesDao(SingleInstance.getDatabaseHelper()) .removeSensor(sensors.get(lastLongClickItem).getSensorId()); } catch (SQLException e) { publishProgress(false); } publishProgress(true); return null; } @Override protected void onProgressUpdate(Boolean... values) { for (boolean b : values) { if (b) { new AlertDialog.Builder(mActivity).setTitle(R.string.dialog_title_information) .setMessage(R.string.dialog_message_information_sensor_deleted) .setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { EventBus.getDefault().post(new ReloadUserEvent(false)); dialog.dismiss(); } }) .show(); } else { new AlertDialog.Builder(mActivity).setTitle(R.string.dialog_title_information) .setMessage("unknown error while deleting from DB").setPositiveButton( R.string.button_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .show(); } } } }.execute(); dialog.dismiss(); } }); builder.show(); }
From source file:jp.co.rakuten.rakutenvideoplayer.base.BaseActivity.java
/** * Show dialog error/* w w w . ja v a 2 s . co m*/ * @param errStr */ public void showDialogInformation(String errStr) { AlertDialog.Builder adb = new AlertDialog.Builder(this); adb.setIcon(R.drawable.icon); adb.setTitle(R.string.str_ErrPlay_Title); adb.setMessage(errStr); adb.setPositiveButton(R.string.str_OK, new OnClickListener() { public void onClick(DialogInterface a0, int a1) { return; } }); AlertDialog ad = adb.create(); ad.show(); }
From source file:kn.uni.gis.foxhunt.GameActivity.java
@Override public void onBackPressed() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setCancelable(false);// w w w. j a v a 2s .co m builder.setMessage(getString(R.string.GAME_BACK_DESC)); builder.setTitle(getString(R.string.GAME_BACK_TITLE)); builder.setNegativeButton(R.string.GAME_BACK_OK, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { GameActivity.this.finish(); } }).setPositiveButton(getString(R.string.GAME_BACK_CANCEL), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // NOOP } }).create().show(); }
From source file:com.cricketkorner.cricket.VitamioListActivity.java
private void ListFunction() { listView = (ListView) findViewById(R.id.listView); //copying array for (int i = 0; i < Singleton.getInstance().getChannelList().size(); i++) { title.add(Singleton.getInstance().getChannelList().get(i).getChannelName()); desc.add("Long Press This Channel To Report, Id: " + Singleton.getInstance().getChannelList().get(i).getChannelId()); thumb.add(R.drawable.ic_launcher); }//w ww . ja v a 2 s .c o m listView.setAdapter(new VersionAdapter(VitamioListActivity.this)); listView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) { AlertDialog.Builder alert = new AlertDialog.Builder(VitamioListActivity.this); alert.setTitle("Report Broken Link"); alert.setMessage("Message: (Channel not working?)"); // Set an EditText view to get user input final EditText input = new EditText(VitamioListActivity.this); alert.setView(input); alert.setPositiveButton("Submit", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); if (isNetworkAvailable()) { new ReportFeedback().execute("http://yoururl.com/LiveStreaming/reportFeedback.php", value, Singleton.getInstance().getChannelList().get(position).getChannelId()); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); return false; } }); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { int pos = arg2; LayoutInflater layoutInflator = getLayoutInflater(); View layout = layoutInflator.inflate(R.layout.custom_toast, (ViewGroup) findViewById(R.id.toast_layout_root)); ImageView iv = (ImageView) layout.findViewById(R.id.toast_iv); TextView tv = (TextView) layout.findViewById(R.id.toast_tv); iv.setBackgroundResource(thumb.get(pos)); tv.setText(title.get(pos)); Intent intent = new Intent(VitamioListActivity.this, VideoViewDemo.class); intent.putExtra("path", Singleton.getInstance().getChannelList().get(pos).getChannelPath()); startAppAd.onBackPressed(); startActivity(intent); } }); }
From source file:com.lepin.activity.MyLoveCarActivity.java
/** * ?//from ww w . ja v a 2s.c o m */ protected void choicePeoPleNumber() { AlertDialog.Builder builder = new AlertDialog.Builder(MyLoveCarActivity.this); builder.setTitle(R.string.pick_details_total_people).setItems(pepNumArry, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mlPeoNum.setText(pepNumArry[which]); } }); builder.create().show(); }
From source file:com.lepin.activity.MyLoveCarActivity.java
/** * //from ww w . j ava2s .c o m */ protected void choiceDriveYear() { AlertDialog.Builder builder = new AlertDialog.Builder(MyLoveCarActivity.this); builder.setTitle(R.string.my_car_choice_dryear).setItems(drYearsArry, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mlDrivYear.setText(drYearsArry[which]); } }); builder.create().show(); }
From source file:com.dtr.zxing.activity.CaptureActivity.java
private void displayFrameworkBugMessageAndExit() { // camera error AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.app_name)); builder.setMessage("???"); builder.setPositiveButton("", new DialogInterface.OnClickListener() { @Override//from w ww . ja va 2 s. c o m public void onClick(DialogInterface dialog, int which) { finish(); } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }); builder.show(); }
From source file:com.rainmakerlabs.bleepsample.BleepService.java
private void showAlertDialog(String title, String msg, String posText, DialogInterface.OnClickListener posFunc, String negText, DialogInterface.OnClickListener negFunc, EditText input) { if (BLEalert != null && BLEalert.isShowing()) { BLEalert.cancel();/* w w w . j a va 2s .c o m*/ } //if (BLEalert == null || !BLEalert.isShowing()) { if (title == null) title = ""; if (msg == null) msg = ""; if (title.equalsIgnoreCase("") && msg.equalsIgnoreCase("")) return; AlertDialog.Builder builder = new AlertDialog.Builder(BleepActivity.currentBleepActivity); builder.setTitle(title); builder.setMessage(msg); if (input != null) builder.setView(input); if (posText != null && !posText.equalsIgnoreCase("")) builder.setPositiveButton(posText, posFunc); if (negText != null && !negText.equalsIgnoreCase("")) builder.setNegativeButton(negText, negFunc); BLEalert = builder.create(); BLEalert.show(); //} }
From source file:com.lepin.activity.CarDriverVerify.java
/** * TODO ?//from ww w . j a v a 2s . co m * * @author {author wangxiaohong} */ private void selectImage() { // TODO Auto-generated method stub String state = Environment.getExternalStorageState(); if (!state.equals(Environment.MEDIA_MOUNTED)) { Util.showToast(this, getResources().getString(R.string.check_sd)); return; } AlertDialog.Builder builder = new AlertDialog.Builder(CarDriverVerify.this); builder.setTitle(R.string.pick_image).setItems(image, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (image[which].equals(getString(R.string.my_data_image_way_photo))) { getImageByPhoto(); } else { getImageByGallery(); } } }); builder.create().show(); }