List of usage examples for android.app AlertDialog.Builder create
public void create()
From source file:se.anyro.tagtider.TransferActivity.java
private AlertDialog createC2dmDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.c2dm_dialog_title); builder.setMessage(R.string.c2dm_dialog_message); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override//w w w.ja v a 2 s .c o m public void onClick(DialogInterface dialog, int which) { if (mRegistrationId == null) { registerC2dm(); } else { new StartSubscriptionTask().execute(mRegistrationId, TYPE_AC2DM); } } }); builder.setNegativeButton("Avbryt", null); final AlertDialog smsDialog = builder.create(); return smsDialog; }
From source file:org.csware.ee.utils.Tools.java
public static void show(final Activity activity, final int id) { final Context context = activity; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(""); builder.setMessage(""); builder.setPositiveButton("", new DialogInterface.OnClickListener() { @Override/*from w ww.j av a 2 s . c om*/ public void onClick(DialogInterface dialog, int which) { int version = android.os.Build.VERSION.SDK_INT; Intent intent; if (version < 11) { intent = new Intent(); intent.setClassName("com.android.settings", "com.android.settings.WirelessSettings"); } else { //3.0? //intent = new Intent( android.provider.Settings.ACTION_WIRELESS_SETTINGS); intent = new Intent(android.provider.Settings.ACTION_SETTINGS); } if (id == 1) { activity.finish(); } context.startActivity(intent); } }); builder.setNegativeButton("?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (id == 1) { activity.finish(); } } }); builder.create().show(); }
From source file:MainActivity.java
public void confirmDelete(View view) { // String[] countries = new String[]{"China", "France", "Germany", "India", "Russia", "United Kingdom", "United States"}; // ListAdapter countryAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, countries); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Delete") //.setIcon(R.mipmap.ic_launcher) .setMessage("Are you sure you?") // .setAdapter(countryAdapter, new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // Toast.makeText(MainActivity.this, countries[which] + " clicked", Toast.LENGTH_SHORT).show(); // } // }) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Toast.makeText(MainActivity.this, "OK Pressed", Toast.LENGTH_SHORT).show(); }//from www . j a v a 2 s . co m }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Toast.makeText(MainActivity.this, "Cancel Pressed", Toast.LENGTH_SHORT).show(); } }); builder.create().show(); }
From source file:jp.co.rakuten.rakutenvideoplayer.base.BaseActivity.java
/** * Show dialog error//from w w w . j a v a2 s. c o m * @param errStr */ public void showDialogError(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) { finish(); } }); adb.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { dialog.dismiss(); finish(); return true; } return false; } }); AlertDialog ad = adb.create(); ad.show(); }
From source file:com.dnielfe.manager.dialogs.FilePropertiesDialog.java
@Override public Dialog onCreateDialog(Bundle state) { activity = getActivity();/* www .j av a 2 s . c om*/ final AlertDialog.Builder builder = new AlertDialog.Builder(activity); mAdapter = new PropertiesAdapter(activity, mFile); builder.setTitle(mFile.getName()); builder.setNeutralButton(R.string.cancel, null); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final FilePermissionsPagerItem fragment = (FilePermissionsPagerItem) mAdapter.getItem(1); fragment.applyPermissions(getActivity()); } }); final View content = activity.getLayoutInflater().inflate(R.layout.dialog_properties_container, null); this.initView(content); builder.setView(content); final AlertDialog dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(final DialogInterface dialog) { ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE).setVisibility(View.GONE); } }); return dialog; }
From source file:org.safegees.safegees.gui.view.MainActivity.java
private void setPermissionsAlertDialog(String message) { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(message).setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent i = getBaseContext().getPackageManager() .getLaunchIntentForPackage(getBaseContext().getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i);//from w w w. j a v a 2 s. com //finish(); } }).setNegativeButton("EXIT", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:cm.aptoide.pt.Aptoide.java
private void requestUpdateSelf() { AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); alertBuilder.setCancelable(false)/*from w ww .j av a2 s .c o m*/ .setPositiveButton(R.string.dialog_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); new DownloadSelfUpdate().execute(); } }).setNegativeButton(R.string.dialog_no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); proceed(); } }).setMessage(R.string.update_self_msg); AlertDialog alert = alertBuilder.create(); alert.setTitle(R.string.update_self_title); alert.setIcon(R.drawable.icon); alert.show(); }
From source file:com.abc.driver.TruckActivity.java
public void chooseTruckWeight(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(this); GridView gridView1 = new GridView(this); gridView1.setNumColumns(3);/*from w w w . ja v a2 s . c o m*/ SimpleAdapter adapter = new SimpleAdapter(this, mTruckWeightList, R.layout.truck_weight_griditem, new String[] { "TITLE", "TWEIGHT" }, new int[] { R.id.griditem_title, R.id.griditem_weight, }); gridView1.setAdapter(adapter); builder.setTitle("Please Choose"); builder.setInverseBackgroundForced(true); builder.setView(gridView1); final Dialog dialog = builder.create(); gridView1.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) { mTWtv.setText(((TextView) view.findViewById(R.id.griditem_title)).getText()); mTruckWeight = ((TextView) view.findViewById(R.id.griditem_weight)).getText().toString(); mUpdateTruckTask = new UpdateTruckTask(); mUpdateTruckTask.execute("" + app.getUser().getMyTruck().getTruckId(), "" + app.getUser().getMyTruck().getTypeId(), "" + app.getUser().getMyTruck().getLengthId(), mTruckWeight, "" + app.getUser().getMyTruck().getStatusId(), "" + app.getUser().getId()); dialog.dismiss(); } }); dialog.show(); }
From source file:it.scoppelletti.mobilepower.app.HelpDialogFragment.java
/** * Crea il dialogo./*from w w w .java2s . c o m*/ * * @param savedInstanceState Stato dell’istanza. * @return Dialogo. */ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { int mode, resId; View contentView; AlertDialog dlg; AlertDialog.Builder builder; LayoutInflater inflater; TextView textControl; Bundle args = getArguments(); builder = newAlertDialogBuilder(); resId = args.getInt(HelpDialogFragment.ARG_TITLEID, 0); if (resId > 0) { builder.setTitle(resId); } inflater = getActivity().getLayoutInflater(); contentView = inflater.inflate(R.layout.helpdialog, null); builder.setView(contentView); builder.setIcon(android.R.drawable.ic_dialog_info); mode = getArguments().getInt(HelpDialogFragment.ARG_MODE, HelpDialogFragment.MODE_HELP); switch (mode) { case HelpDialogFragment.MODE_CONFIRM: setCancelable(false); builder.setCancelable(false); builder.setPositiveButton(R.string.cmd_proceed, this); builder.setNegativeButton(android.R.string.cancel, this); break; default: // HelpDialogFragment.MODE_HELP builder.setNeutralButton(R.string.cmd_close, null); break; } dlg = builder.create(); textControl = (TextView) contentView.findViewById(R.id.txt_help); textControl.setKeyListener(null); resId = args.getInt(HelpDialogFragment.ARG_TEXTID, 0); if (resId > 0) { textControl.setText(Html.fromHtml(getResources().getString(resId))); } return dlg; }