List of usage examples for android.app AlertDialog show
public void show()
From source file:com.abc.driver.PersonalActivity.java
private void doCrop() { Log.d(TAG, "doCrop()"); final ArrayList<CropOption> cropOptions = new ArrayList<CropOption>(); Intent intent = new Intent("com.android.camera.action.CROP"); intent.setType("image/*"); List<ResolveInfo> list = this.getPackageManager().queryIntentActivities(intent, 0); int size = list.size(); if (size == 0) { Log.d(TAG, " Crop activity is not found. List size is zero."); Bitmap tmpBmp = BitmapFactory.decodeFile(imageUri.getPath(), null); app.setPortaritBitmap(Bitmap.createScaledBitmap(tmpBmp, CellSiteConstants.IMAGE_WIDTH, CellSiteConstants.IMAGE_HEIGHT, false)); mUserPortraitIv.setImageBitmap(app.getPortaritBitmap()); isPortraitChanged = true;//from w ww. j ava 2 s.co m Log.d(TAG, "set bitmap"); return; } else { Log.d(TAG, "found the crop activity."); intent.setData(imageUri); intent.putExtra("outputX", CellSiteConstants.IMAGE_WIDTH); intent.putExtra("outputY", CellSiteConstants.IMAGE_HEIGHT); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("scale", true); intent.putExtra("return-data", true); if (size == 1) { Log.d(TAG, "Just one as choose it as crop activity."); Intent i = new Intent(intent); ResolveInfo res = list.get(0); i.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); startActivityForResult(i, CellSiteConstants.CROP_PICTURE); } else { Log.d(TAG, "More that one activity for crop is found . will chooose one"); for (ResolveInfo res : list) { final CropOption co = new CropOption(); co.title = getPackageManager().getApplicationLabel(res.activityInfo.applicationInfo); co.icon = getPackageManager().getApplicationIcon(res.activityInfo.applicationInfo); co.appIntent = new Intent(intent); co.appIntent .setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); cropOptions.add(co); } CropOptionAdapter adapter = new CropOptionAdapter(getApplicationContext(), cropOptions); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Choose Crop App"); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { startActivityForResult(cropOptions.get(item).appIntent, CellSiteConstants.CROP_PICTURE); } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { // @Override public void onCancel(DialogInterface dialog) { if (imageUri != null) { getContentResolver().delete(imageUri, null, null); imageUri = null; isPortraitChanged = false; } } }); AlertDialog alert = builder.create(); alert.show(); } } }
From source file:de.baumann.hhsmoodle.data_random.Random_Fragment.java
private void setRandomList() { if (isFABOpen) { closeFABMenu();//from w w w . ja v a2 s.co m } //display data final int layoutstyle = R.layout.list_item_notes; int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }; String[] column = new String[] { "random_title", "random_content", "random_creation" }; final Cursor row = db.fetchAllData(); SimpleCursorAdapter adapter = new SimpleCursorAdapter(getActivity(), layoutstyle, row, column, xml_id, 0) { @Override public View getView(final int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); ImageView iv_icon = (ImageView) v.findViewById(R.id.icon_notes); iv_icon.setVisibility(View.GONE); return v; } }; lv.setAdapter(adapter); //onClick function lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { if (isFABOpen) { closeFABMenu(); } Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String random_content = row2.getString(row2.getColumnIndexOrThrow("random_content")); final String random_title = row2.getString(row2.getColumnIndexOrThrow("random_title")); if (random_content.isEmpty()) { Snackbar.make(lv, getActivity().getString(R.string.number_enterData), Snackbar.LENGTH_LONG) .show(); } else { getActivity().setTitle(random_title); lv.setVisibility(View.GONE); lvItems.setVisibility(View.VISIBLE); try { FileOutputStream fOut = new FileOutputStream(newFile()); OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut); myOutWriter.append(random_content); myOutWriter.close(); fOut.flush(); fOut.close(); } catch (IOException e) { Log.e("Exception", "File write failed: " + e.toString()); } items = new ArrayList<>(); readItems(); setAdapter(1000); fab.setVisibility(View.GONE); fab_dice.setVisibility(View.VISIBLE); } } }); lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { if (isFABOpen) { closeFABMenu(); } Cursor row2 = (Cursor) lv.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String random_title = row2.getString(row2.getColumnIndexOrThrow("random_title")); final String random_content = row2.getString(row2.getColumnIndexOrThrow("random_content")); final String random_icon = row2.getString(row2.getColumnIndexOrThrow("random_icon")); final String random_attachment = row2.getString(row2.getColumnIndexOrThrow("random_attachment")); final String random_creation = row2.getString(row2.getColumnIndexOrThrow("random_creation")); final CharSequence[] options = { getString(R.string.number_edit_entry), getString(R.string.bookmark_remove_bookmark) }; new android.app.AlertDialog.Builder(getActivity()) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.number_edit_entry))) { android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder( getActivity()); View dialogView = View.inflate(getActivity(), R.layout.dialog_edit_entry, null); final EditText edit_title = (EditText) dialogView .findViewById(R.id.note_title_input); edit_title.setHint(R.string.title_hint); edit_title.setText(random_title); final EditText edit_cont = (EditText) dialogView .findViewById(R.id.note_text_input); edit_cont.setHint(R.string.text_hint); edit_cont.setText(random_content); builder.setView(dialogView); builder.setTitle(R.string.number_edit_entry); builder.setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String inputTitle = edit_title.getText().toString().trim(); String inputCont = edit_cont.getText().toString().trim(); db.update(Integer.parseInt(_id), inputTitle, inputCont, random_icon, random_attachment, random_creation); setRandomList(); Snackbar.make(lv, R.string.bookmark_added, Snackbar.LENGTH_SHORT).show(); } }); builder.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); final android.app.AlertDialog dialog2 = builder.create(); // Display the custom alert dialog on interface dialog2.show(); helper_main.showKeyboard(getActivity(), edit_title); } if (options[item].equals(getString(R.string.bookmark_remove_bookmark))) { Snackbar snackbar = Snackbar .make(lv, R.string.note_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { db.delete(Integer.parseInt(_id)); setRandomList(); } }); snackbar.show(); } } }).show(); return true; } }); }
From source file:org.kde.necessitas.ministro.MinistroActivity.java
private void checkNetworkAndDownload(final boolean update) { if (isOnline(this)) new CheckLibraries().execute(update); else {//from ww w .j a v a 2s .c o m AlertDialog.Builder builder = new AlertDialog.Builder(MinistroActivity.this); builder.setMessage(getResources().getString(R.string.ministro_network_access_msg)); builder.setCancelable(true); builder.setNeutralButton(getResources().getString(R.string.settings_msg), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { final ProgressDialog m_dialog = ProgressDialog.show(MinistroActivity.this, null, getResources().getString(R.string.wait_for_network_connection_msg), true, true, new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { finishMe(); } }); getApplication().registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (isOnline(MinistroActivity.this)) { try { getApplication().unregisterReceiver(this); } catch (Exception e) { e.printStackTrace(); } runOnUiThread(new Runnable() { public void run() { m_dialog.dismiss(); new CheckLibraries().execute(update); } }); } } }, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); try { startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); } catch (Exception e) { e.printStackTrace(); try { startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); } catch (Exception e1) { e1.printStackTrace(); } } dialog.dismiss(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { finishMe(); } }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:com.mercandalli.android.apps.files.file.cloud.FileMyCloudFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_file_files, container, false); final Activity activity = getActivity(); final String succeed = "succeed"; mProgressBar = (ProgressBar) rootView.findViewById(R.id.circularProgressBar); mMessageTextView = (TextView) rootView.findViewById(R.id.message); mSwipeRefreshLayout = (SwipeRefreshLayout) rootView .findViewById(R.id.fragment_file_files_swipe_refresh_layout); mSwipeRefreshLayout.setOnRefreshListener(this); mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.fragment_file_files_recycler_view); mRecyclerView.setHasFixedSize(true); final int nbColumn = getResources().getInteger(R.integer.column_number_card); if (nbColumn <= 1) { mRecyclerView.setLayoutManager(new LinearLayoutManager(activity)); } else {//from ww w. j av a 2 s . com mRecyclerView.setLayoutManager(new GridLayoutManager(activity, nbColumn)); } resetPath(); mFileModelAdapter = new FileModelAdapter(getContext(), mFilesList, new FileModelListener() { @Override public void executeFileModel(final FileModel fileModel, final View view) { final AlertDialog.Builder menuAlert = new AlertDialog.Builder(getContext()); String[] menuList = { getString(R.string.download), getString(R.string.rename), getString(R.string.delete), getString(R.string.cut), getString(R.string.properties) }; if (!fileModel.isDirectory()) { if (FileTypeModelENUM.IMAGE.type.equals(fileModel.getType())) { menuList = new String[] { getString(R.string.download), getString(R.string.rename), getString(R.string.delete), getString(R.string.cut), getString(R.string.properties), (fileModel.isPublic()) ? "Become private" : "Become public", "Set as profile" }; } else if (FileTypeModelENUM.APK.type.equals(fileModel.getType()) && Config.isUserAdmin()) { menuList = new String[] { getString(R.string.download), getString(R.string.rename), getString(R.string.delete), getString(R.string.cut), getString(R.string.properties), (fileModel.isPublic()) ? "Become private" : "Become public", (fileModel.isApkUpdate()) ? "Remove the update" : "Set as update" }; } else { menuList = new String[] { getString(R.string.download), getString(R.string.rename), getString(R.string.delete), getString(R.string.cut), getString(R.string.properties), (fileModel.isPublic()) ? "Become private" : "Become public" }; } } menuAlert.setTitle(getString(R.string.action)); menuAlert.setItems(menuList, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { switch (item) { case 0: mFileManager.download(getActivity(), fileModel, new IListener() { @Override public void execute() { Toast.makeText(getContext(), "Download finished.", Toast.LENGTH_SHORT).show(); } }); break; case 1: DialogUtils.prompt(getActivity(), "Rename", "Rename " + (fileModel.isDirectory() ? "directory" : "file") + " " + fileModel.getName() + " ?", "Ok", new DialogUtils.OnDialogUtilsStringListener() { @Override public void onDialogUtilsStringCalledBack(String text) { mFileManager.rename(fileModel, text, new IListener() { @Override public void execute() { if (mFilesToCutList.size() != 0) { mFilesToCutList.clear(); mFileCloudFabManager.updateFabButtons(); } refreshCurrentList(); } }); } }, "Cancel", null, fileModel.getFullName()); break; case 2: DialogUtils.alert(getActivity(), "Delete", "Delete " + (fileModel.isDirectory() ? "directory" : "file") + " " + fileModel.getName() + " ?", "Yes", new DialogUtils.OnDialogUtilsListener() { @Override public void onDialogUtilsCalledBack() { mFileManager.delete(fileModel, new IListener() { @Override public void execute() { if (mFilesToCutList.size() != 0) { mFilesToCutList.clear(); mFileCloudFabManager.updateFabButtons(); } refreshCurrentList(); } }); } }, "No", null); break; case 3: mFilesToCutList.add(fileModel); Toast.makeText(getContext(), "File ready to cut.", Toast.LENGTH_SHORT).show(); mFileCloudFabManager.updateFabButtons(); break; case 4: DialogUtils.alert(getActivity(), getString(R.string.properties) + " : " + fileModel.getName(), mFileManager.toSpanned(getContext(), fileModel), "OK", null, null, null); Html.fromHtml(""); break; case 5: mFileManager.setPublic(fileModel, !fileModel.isPublic(), new IListener() { @Override public void execute() { } }); break; case 6: // Picture set as profile if (FileTypeModelENUM.IMAGE.type.equals(fileModel.getType())) { List<StringPair> parameters = new ArrayList<>(); parameters.add(new StringPair("id_file_profile_picture", "" + fileModel.getId())); (new TaskPost(getActivity(), Constants.URL_DOMAIN + Config.ROUTE_USER_PUT, new IPostExecuteListener() { @Override public void onPostExecute(JSONObject json, String body) { try { if (json != null && json.has(succeed) && json.getBoolean(succeed)) { Config.setUserIdFileProfilePicture(getActivity(), fileModel.getId()); } } catch (JSONException e) { Log.e(getClass().getName(), "Failed to convert Json", e); } } }, parameters)).execute(); } else if (FileTypeModelENUM.APK.type.equals(fileModel.getType()) && Config.isUserAdmin()) { List<StringPair> parameters = new ArrayList<>(); parameters.add(new StringPair("is_apk_update", "" + !fileModel.isApkUpdate())); (new TaskPost(getActivity(), Constants.URL_DOMAIN + Config.ROUTE_FILE + "/" + fileModel.getId(), new IPostExecuteListener() { @Override public void onPostExecute(JSONObject json, String body) { try { if (json != null && json.has(succeed) && json.getBoolean(succeed)) { } } catch (JSONException e) { Log.e(getClass().getName(), "Failed to convert Json", e); } } }, parameters)).execute(); } break; } } }); AlertDialog menuDrop = menuAlert.create(); menuDrop.show(); } }, new FileModelAdapter.OnFileClickListener() { @Override public void onFileClick(View view, int position) { /* if (hasItemSelected()) { mFilesList.get(position).selected = !mFilesList.get(position).selected; mFileModelAdapter.notifyItemChanged(position); } else */ if (mFilesList.get(position).isDirectory()) { mIdFileDirectoryStack.add(mFilesList.get(position).getId()); refreshCurrentList(true); } else { mFileManager.execute(getActivity(), position, mFilesList, view); } } }, new FileModelAdapter.OnFileLongClickListener() { @Override public boolean onFileLongClick(View view, int position) { /* mFilesList.get(position).selected = !mFilesList.get(position).selected; mFileModelAdapter.notifyItemChanged(position); */ return true; } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { scaleAnimationAdapter = new ScaleAnimationAdapter(mRecyclerView, mFileModelAdapter); scaleAnimationAdapter.setDuration(220); scaleAnimationAdapter.setOffsetDuration(32); mRecyclerView.setAdapter(scaleAnimationAdapter); } else { mRecyclerView.setAdapter(mFileModelAdapter); } refreshCurrentList(true); return rootView; }
From source file:net.networksaremadeofstring.cyllell.Search.java
public void MakeHandler() { handler = new Handler() { public void handleMessage(Message msg) { //Once we've checked the data is good to use start processing it if (msg.what == 0) { //TODO ListView population NodeAdapter = new NodeListAdaptor(Search.this, listOfNodes); list.setAdapter(NodeAdapter); //Close the Progress dialog dialog.dismiss();/* w w w. j av a 2s . c o m*/ } else if (msg.what == 200) { dialog.setMessage("Searching for: " + query + "\n\nSending request to Chef..."); } else if (msg.what == 201) { dialog.setMessage("Parsing JSON....."); } else if (msg.what == 202) { dialog.setMessage("Populating UI!"); } else { //Close the Progress dialog dialog.dismiss(); //Alert the user that something went terribly wrong AlertDialog alertDialog = new AlertDialog.Builder(Search.this).create(); alertDialog.setTitle("API Error"); alertDialog.setMessage("There was an error communicating with the API:\n" + msg.getData().getString("exception")); alertDialog.setButton2("Back", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Search.this.finish(); } }); alertDialog.setIcon(R.drawable.error); alertDialog.show(); } } }; }
From source file:eu.dirtyharry.androidopsiadmin.Main.java
public void getOPSIDepots() { final ProgressDialog dialog = ProgressDialog.show(Main.this, getString(R.string.gen_title_pleasewait), getString(R.string.pd_getdepots), true); final Handler handler = new Handler() { public void handleMessage(Message msg) { dialog.dismiss();/* w w w. j av a 2 s .c om*/ if (GlobalVar.getInstance().getError().equals("null")) { if (doit.equals("true")) { JSONArray result = new JSONArray(); try { result = opsiresult.getJSONArray("result"); depots = new String[result.length()]; for (int i = 0; i < result.length(); i++) { depots[i] = result.getString(i); } } catch (JSONException e) { e.printStackTrace(); } AlertDialog.Builder builder = new AlertDialog.Builder(Main.this); builder.setTitle(getString(R.string.gen_choose)); builder.setSingleChoiceItems(depots, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { dialog.dismiss(); String depot = depots[item]; choosendepot = depot; getOPSIDepotConfig(depot); } }); AlertDialog alert = builder.create(); alert.show(); } else if (doit.equals("serverdown")) { Toast.makeText(Main.this, String.format(getString(R.string.to_servernotrechable), serverip), // serverip + " " // + getString(R.string.to_servernotrechable), Toast.LENGTH_LONG).show(); } } else { new Functions().msgBox(Main.this, getString(R.string.gen_title_error), GlobalVar.getInstance().getError(), false); } } }; Thread checkUpdate = new Thread() { public void run() { Looper.prepare(); JSONArray JSONparams = new JSONArray(); if (Networking.isServerUp(serverip, serverport, serverusername, serverpasswd)) { opsiresult = new JSONObject(); opsiresult = eu.dirtyharry.androidopsiadmin.Networking.opsiGetJSONObject("rpc", serverip, serverport, "getDepotIds_list", JSONparams, serverusername, serverpasswd); doit = "true"; } else { doit = "serverdown"; // } handler.sendEmptyMessage(0); } }; checkUpdate.start(); }
From source file:com.abc.driver.TruckActivity.java
private void doCrop() { Log.d(TAG, "doCrop()"); final ArrayList<CropOption> cropOptions = new ArrayList<CropOption>(); Intent intent = new Intent("com.android.camera.action.CROP"); intent.setType("image/*"); List<ResolveInfo> list = this.getPackageManager().queryIntentActivities(intent, 0); int size = list.size(); if (size == 0) { Log.d(TAG, " Crop activity is not found. List size is zero."); Bitmap tmpBmp = BitmapFactory.decodeFile(imageUri.getPath(), null); trcukLicenseBmp = Bitmap.createScaledBitmap(tmpBmp, IMAGE_WIDTH, IMAGE_HEIGHT, false); mTLPiv.setImageBitmap(trcukLicenseBmp); isPortraitChanged = true;/*from www . j a v a 2s.c om*/ Log.d(TAG, "set bitmap"); return; } else { Log.d(TAG, "found the crop activity."); intent.setData(imageUri); intent.putExtra("outputX", IMAGE_WIDTH); intent.putExtra("outputY", IMAGE_HEIGHT); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("scale", true); intent.putExtra("return-data", true); if (size == 1) { Log.d(TAG, "Just one as choose it as crop activity."); Intent i = new Intent(intent); ResolveInfo res = list.get(0); i.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); startActivityForResult(i, CellSiteConstants.CROP_PICTURE); } else { Log.d(TAG, "More that one activity for crop is found . will chooose one"); for (ResolveInfo res : list) { final CropOption co = new CropOption(); co.title = getPackageManager().getApplicationLabel(res.activityInfo.applicationInfo); co.icon = getPackageManager().getApplicationIcon(res.activityInfo.applicationInfo); co.appIntent = new Intent(intent); co.appIntent .setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); cropOptions.add(co); } CropOptionAdapter adapter = new CropOptionAdapter(getApplicationContext(), cropOptions); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Choose Crop App"); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { startActivityForResult(cropOptions.get(item).appIntent, CellSiteConstants.CROP_PICTURE); } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { // @Override public void onCancel(DialogInterface dialog) { if (imageUri != null) { getContentResolver().delete(imageUri, null, null); imageUri = null; isPortraitChanged = false; } } }); AlertDialog alert = builder.create(); alert.show(); } } }
From source file:se.anyro.tagtider.TransferActivity.java
private void setupDialogs() { final AlertDialog smsDialog = createSmsDialog(); Button sendSmsButton = (Button) findViewById(R.id.sms); sendSmsButton.setOnClickListener(new OnClickListener() { @Override//w ww .ja v a2 s . c o m public void onClick(View v) { smsDialog.show(); } }); final AlertDialog c2dmDialog = createC2dmDialog(); Button sendC2dmButton = (Button) findViewById(R.id.c2dm); sendC2dmButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { c2dmDialog.show(); } }); mProgressDialog = new ProgressDialog(this); mDialog = new AlertDialog.Builder(this).setNeutralButton("Ok", null).create(); }
From source file:bikebadger.RideFragment.java
private void ShowAlertMessageNoGps() { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage("GPS seems to be disabled. Do you wish to enable it?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)); }/*from w w w . j a v a 2 s . co m*/ }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { dialog.cancel(); } }); final AlertDialog alert = builder.create(); alert.show(); }
From source file:com.nadmm.airports.DownloadActivity.java
private void checkDelete() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Are you sure you want to delete all installed data?") .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override/*ww w . j ava 2 s . c o m*/ public void onClick(DialogInterface dialog, int id) { DeleteDataTask deleteTask = new DeleteDataTask(); deleteTask.execute((Void) null); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { } }); AlertDialog alert = builder.create(); alert.show(); return; }