List of usage examples for android.app AlertDialog.Builder show
public void show()
From source file:at.alladin.rmbt.android.test.RMBTTestFragment.java
public boolean onBackPressedHandler() { Log.d("RMBTTestFragment", "onbackpressed"); final RMBTMainActivity activity = (RMBTMainActivity) getActivity(); if (activity == null) return false; if ((errorDialog != null && errorDialog.isShowing()) || (progressDialog != null && progressDialog.isShowing())) { if (rmbtService != null) rmbtService.stopTest(RMBTService.BROADCAST_TEST_ABORTED); else {//from w ww . ja v a 2 s .co m // to be sure test is stopped: final Intent service = new Intent(RMBTService.ACTION_ABORT_TEST, null, context, RMBTService.class); context.startService(service); } dismissDialogs(); activity.getSupportFragmentManager().popBackStack(); return true; } if (abortDialog != null && abortDialog.isShowing()) { dismissDialog(abortDialog); abortDialog = null; } else { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.test_dialog_abort_title); builder.setMessage(R.string.test_dialog_abort_text); builder.setPositiveButton(R.string.test_dialog_abort_yes, new OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { if (rmbtService != null) rmbtService.stopTest(RMBTService.BROADCAST_TEST_ABORTED); getActivity().getSupportFragmentManager().popBackStack(); } }); builder.setNegativeButton(R.string.test_dialog_abort_no, null); dismissDialogs(); abortDialog = builder.show(); } return true; }
From source file:com.rsltc.profiledata.main.MainActivity.java
private void showSaveDialog(final List<JSONObject> jsonObjectList) { AlertDialog.Builder builder = new AlertDialog.Builder(thisActivity); builder.setTitle("Dataset title"); final EditText input = new EditText(thisActivity); input.setInputType(InputType.TYPE_CLASS_TEXT); builder.setView(input);//w w w . j av a 2s. c o m builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final String m_Text = input.getText().toString(); Runnable r = new Runnable() { @Override public void run() { exportFile(jsonObjectList, m_Text); } }; Thread t = new Thread(r); t.start(); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); }
From source file:com.pursuer.reader.easyrss.VerticalSingleItemView.java
private void updateButtonSharing() { final View btnSharing = menu.findViewById(R.id.BtnSharing); btnSharing.setOnClickListener(new OnClickListener() { @Override/* w w w . j a v a2 s. com*/ public void onClick(final View view) { final AlertDialog.Builder builder = new AlertDialog.Builder( new ContextThemeWrapper(context, android.R.style.Theme_DeviceDefault_Dialog)); final String[] popup = new String[] { context.getString(R.string.TxtSendTo), context.getString(R.string.TxtSendItemTextTo), context.getString(R.string.TxtSendItemContentTo), context.getString(R.string.TxtCopyToClipboard) }; builder.setItems(popup, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialogInterface, final int id) { switch (id) { case 0: DataUtils.sendTo(context, item); break; case 1: DataUtils.sendContentTo(context, item); break; case 2: DataUtils.sendHtmlContentTo(context, item); break; case 3: DataUtils.copyToClipboard(context, item); default: } } }); builder.show(); } }); }
From source file:mp.paschalis.RequestActivity.java
/** * Lents a book to user//w w w . ja v a 2 s.com */ private void hButtonLentABook() { buttonHybrid.setText(R.string.lent); buttonHybrid.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { { AlertDialog.Builder alert = new AlertDialog.Builder(RequestActivity.this); alert.setTitle(R.string.msg_sure); alert.setIcon(R.drawable.ic_menu_back); alert.setNegativeButton(R.string.no, new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); alert.setPositiveButton(R.string.yes, new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Lent a book LentBookActivity.DataClassLentABook data = new LentBookActivity.DataClassLentABook(); data.destinationUser = dataClassActivities.username; data.isbn = dataClassActivities.book.isbn; new AsyncTaskLentABook_Activities().execute(data); } }); alert.show(); } } }); }
From source file:mp.paschalis.RequestActivity.java
/** * Replies to request of user//ww w . j ava2s . co m */ private void hButtonDeleteRequest() { buttonHybrid.setText(R.string.deleteRequest); buttonHybrid.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { { AlertDialog.Builder alert = new AlertDialog.Builder(RequestActivity.this); alert.setTitle(R.string.msg_sure); alert.setIcon(R.drawable.ic_dialog_alert_holo_light); alert.setNegativeButton(R.string.no, new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); alert.setPositiveButton(R.string.yes, new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Delete a request LentBookActivity.DataClassLentABook d = new LentBookActivity.DataClassLentABook(); d.destinationUser = dataClassActivities.username; d.isbn = dataClassActivities.book.isbn; new AsyncTaskDeleteABookRequest().execute(d); } }); alert.show(); } } }); }
From source file:com.intel.xdk.device.Device.java
public void runInstallNativeApp(String appname, String runcommand, String installurl, String bundleid) { Intent LaunchIntent = null;/*from ww w .ja va2 s . co m*/ strStoreUrl = installurl; try { LaunchIntent = activity.getPackageManager().getLaunchIntentForPackage(bundleid); } catch (Exception e) { } if (LaunchIntent == null) { AlertDialog.Builder alertBldr = new AlertDialog.Builder(activity); alertBldr.setMessage( "You don't have " + appname + " installed. Please touch OK to install from the Market."); alertBldr.setTitle("Missing Application"); alertBldr.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { launchStore(); } }); alertBldr.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); alertBldr.show(); } else { activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(runcommand))); strStoreUrl = ""; } }
From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentSearch.java
private void InitiateClick() { listContainer.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override/*from ww w . j av a2 s . c o m*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { mealId1 = mItem.get(position - 1).getID(); mealBrand = mItem.get(position - 1).getBrand(); mealFaborite = "false"; AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity()) .setTitle("Choose Meal: "); final ArrayAdapter<String> mAdapterMoveMeal = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1); mAdapterMoveMeal.add("Snack"); mAdapterMoveMeal.add("Breakfast"); mAdapterMoveMeal.add("Lunch"); mAdapterMoveMeal.add("Dinner"); builderSingle.setNegativeButton("cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builderSingle.setAdapter(mAdapterMoveMeal, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String strName = mAdapterMoveMeal.getItem(which); Intent i = new Intent(getActivity(), SaveSearchAddItemActivityMain.class); i.putExtra(Globals.MEAL_TYPE, strName); i.putExtra(Globals.MEAL_FAVORITE, "false"); i.putExtra(Globals.MEAL_ID, mealId1); i.putExtra(Globals.MEAL_BRAND, mealBrand); startActivity(i); } }); builderSingle.show(); } }); }
From source file:com.corporatetaxi.TaxiOntheWay_Activity.java
public void caceldialog() { AlertDialog.Builder builder = new AlertDialog.Builder(TaxiOntheWay_Activity.this); //builder.setTitle(getString(R.string.cancel_trip)); //builder.setIcon(R.drawable.ic_launcher); LayoutInflater inflater = getLayoutInflater(); View header = inflater.inflate(R.layout.dialog_heading, null); TextView textView = (TextView) header.findViewById(R.id.text); ImageView icon = (ImageView) header.findViewById(R.id.icon); icon.setImageResource(R.drawable.ic_launcher); textView.setText("Taxi On The Way"); builder.setCustomTitle(header);//ww w . j ava2 s . c om builder.setCancelable(false); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // AppPreferences.setTripId(DrawerMainActivity.this, ""); // AppPreferences.setDriverId(DrawerMainActivity.this, ""); dialog.dismiss(); } }); builder.show(); }
From source file:pl.bcichecki.rms.client.android.activities.LoginActivity.java
protected void performLogin() { Log.d(TAG, "Performing login... [username=" + username + ", password=" + password + "]"); profileRestClient = new ProfileRestClient(CONTEXT, username, password, SharedPreferencesWrapper.getServerRealm(), SharedPreferencesWrapper.getServerAddress(), SharedPreferencesWrapper.getServerPort(), SharedPreferencesWrapper.getWebserviceContextPath()); profileRestClient.getProfile(new GsonHttpResponseHandler<User>(new TypeToken<User>() { }.getType(), true) {/* w w w . j a v a 2s . c o m*/ @Override public void onFailure(Throwable error, String content) { Log.d(TAG, "Getting profile failed! [error=" + error + ", content=" + content + "]"); AlertDialog.Builder errorDialog = new AlertDialog.Builder(CONTEXT); errorDialog.setIcon(android.R.drawable.ic_dialog_alert); if (error instanceof HttpResponseException) { if (((HttpResponseException) error).getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { errorDialog.setTitle(R.string.activity_login_unsuccessful_login_message_title); errorDialog.setMessage(R.string.activity_login_unsuccessful_login_message_content); } else { errorDialog.setTitle(R.string.general_unknown_error_message_title); errorDialog .setMessage(String.format(getString(R.string.general_unknown_error_message_content), (HttpResponseException) error)); } } else { errorDialog.setTitle(R.string.general_unknown_error_message_title); errorDialog.setMessage( String.format(getString(R.string.general_unknown_error_message_content), error)); } errorDialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog dialog = errorDialog.show(); TextView messageText = (TextView) dialog.findViewById(android.R.id.message); messageText.setGravity(Gravity.CENTER); } @Override public void onFinish() { showProgress(false); Log.d(TAG, "Getting profile finished."); } @Override public void onStart() { Log.d(TAG, "Getting profile started."); showProgress(true); } @Override public void onSuccess(int statusCode, User user) { Log.d(TAG, "Success [statusCode=" + statusCode + ", jsonObject=" + user.toString() + "]"); UserProfileHolder.setUserProfile(user); UserProfileHolder.setUsername(username); UserProfileHolder.setPassword(password); AppUtils.showCenteredToast(CONTEXT, R.string.activity_login_login_successful, Toast.LENGTH_SHORT); Intent mainActivityIntent = new Intent(CONTEXT, MainActivity.class); startActivity(mainActivityIntent); } }); }