/** Build and show a dialog for user input. Add user input to the white list. */ private void addToWhiteList() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setCancelable(true); builder.setIcon(android.R.drawable.ic_input_add); builder.setTitle(getResources().getString(R.string.AdblockerWhiteListDialogAddTitle)); builder.setInverseBackgroundForced(true); // Set an EditText view to get user input final EditText input = new EditText(this); input.setInputType(InputType.TYPE_TEXT_VARIATION_URI); builder.setView(input); builder.setInverseBackgroundForced(true); builder.setPositiveButton( getResources().getString(R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); doAddToWhiteList(input.getText().toString()); } }); builder.setNegativeButton( getResources().getString(R.string.Cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
/** Show a dialog for choosing the sort mode. Perform the change if required. */ private void changeSortMode() { int currentSort = PreferenceManager.getDefaultSharedPreferences(this) .getInt(Constants.PREFERENCES_BOOKMARKS_SORT_MODE, 0); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setInverseBackgroundForced(true); builder.setIcon(android.R.drawable.ic_dialog_info); builder.setTitle(getResources().getString(R.string.BookmarksListActivity_MenuSortMode)); builder.setSingleChoiceItems( new String[] { getResources().getString(R.string.BookmarksListActivity_AlphaSortMode), getResources().getString(R.string.BookmarksListActivity_RecentSortMode) }, currentSort, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { doChangeSortMode(which); dialog.dismiss(); } }); builder.setCancelable(true); builder.setNegativeButton(R.string.Commons_Cancel, null); AlertDialog alert = builder.create(); alert.show(); }
/** Ask the user the file to import to bookmarks and history, and launch the import. */ private void importHistoryBookmarks() { List<String> exportedFiles = IOUtils.getExportedBookmarksFileList(); final String[] choices = exportedFiles.toArray(new String[exportedFiles.size()]); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setInverseBackgroundForced(true); builder.setIcon(android.R.drawable.ic_dialog_info); builder.setTitle(getResources().getString(R.string.Commons_ImportHistoryBookmarksSource)); builder.setSingleChoiceItems( choices, 0, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { doImportHistoryBookmarks(choices[which]); dialog.dismiss(); } }); builder.setCancelable(true); builder.setNegativeButton(R.string.Commons_Cancel, null); AlertDialog alert = builder.create(); alert.show(); }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder adb = new AlertDialog.Builder(getActivity()); Settings settings = Settings.getInstance(getActivity()); String actionName; switch (getAction()) { case ADD_ACTION: actionName = getString(R.string.add); break; case EDIT_ACTION: actionName = getString(R.string.edit); break; case CONNECT_ACTION: actionName = getString(R.string.connect); break; default: throw new RuntimeException("Unknown action " + getAction()); } adb.setPositiveButton(actionName, null); adb.setNegativeButton(android.R.string.cancel, null); LayoutInflater inflater = LayoutInflater.from(getActivity()); View view = inflater.inflate(R.layout.dialog_server_edit, null, false); TextView titleLabel = (TextView) view.findViewById(R.id.server_edit_name_title); mNameEdit = (EditText) view.findViewById(R.id.server_edit_name); mHostEdit = (EditText) view.findViewById(R.id.server_edit_host); mPortEdit = (EditText) view.findViewById(R.id.server_edit_port); mUsernameEdit = (EditText) view.findViewById(R.id.server_edit_username); mUsernameEdit.setHint(settings.getDefaultUsername()); mPasswordEdit = (EditText) view.findViewById(R.id.server_edit_password); Server oldServer = getServer(); if (oldServer != null) { mNameEdit.setText(oldServer.getName()); mHostEdit.setText(oldServer.getHost()); mPortEdit.setText(String.valueOf(oldServer.getPort())); mUsernameEdit.setText(oldServer.getUsername()); mPasswordEdit.setText(oldServer.getPassword()); } if (shouldIgnoreTitle()) { titleLabel.setVisibility(View.GONE); mNameEdit.setVisibility(View.GONE); } // Fixes issues with text colour on light themes with pre-honeycomb devices. adb.setInverseBackgroundForced(true); adb.setView(view); return adb.create(); }
/** Perform the bookmarks import. */ private void importBookmarks() { List<String> exportedFiles = IOUtils.getExportedBookmarksFileList(); Collections.sort(exportedFiles); final String[] choices = new String[exportedFiles.size() + 1]; choices[0] = this.getResources().getString(R.string.BookmarksListActivity_AndroidImportSource); int i = 1; for (String fileName : exportedFiles) { choices[i] = fileName; i++; } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setInverseBackgroundForced(true); builder.setIcon(android.R.drawable.ic_dialog_info); builder.setTitle(getResources().getString(R.string.BookmarksListActivity_ImportSource)); builder.setSingleChoiceItems( choices, 0, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == 0) { doImportBookmarks(null); } else { doImportBookmarks(choices[which]); } dialog.dismiss(); } }); builder.setCancelable(true); builder.setNegativeButton(R.string.Commons_Cancel, null); AlertDialog alert = builder.create(); alert.show(); }
private void showYesNoDialog( int title, String message, int icon, DialogInterface.OnClickListener onYes) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setCancelable(true); builder.setIcon(icon); builder.setTitle(getResources().getString(title)); builder.setMessage(message); builder.setInverseBackgroundForced(true); builder.setPositiveButton(getResources().getString(R.string.Yes), onYes); builder.setNegativeButton( getResources().getString(R.string.No), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
// 银联 protected void onActivityResult(int requestCode, int resultCode, Intent data) { /** * *********************************************** 步骤3:处理银联手机支付控件返回的支付结果 * ********************************************** */ if (data == null) { return; } String msg = ""; /* * 支付控件返回字符串:success、fail、cancel 分别代表支付成功,支付失败,支付取消 */ String str = data.getExtras().getString("pay_result"); if (str.equalsIgnoreCase("success")) { msg = "支付成功!"; loadData(); } else if (str.equalsIgnoreCase("fail")) { msg = "支付失败!"; } else if (str.equalsIgnoreCase("cancel")) { msg = "用户取消了支付"; } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("支付结果通知"); builder.setMessage(msg); builder.setInverseBackgroundForced(true); // builder.setCustomTitle(); builder.setNegativeButton( "确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); }
public static void ShowAlertDialog( final String title, String message, final Context context, final boolean redirectToPreviousScreen) { try { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(message); builder.setTitle(title); builder.setCancelable(false); builder.setInverseBackgroundForced(true); builder.setPositiveButton( "Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) {} }); AlertDialog alert = builder.create(); alert.show(); } catch (Exception e) { Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show(); } }
/** * Create menu * * @return */ public Dialog createMenu(String menuItitle) { final AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); builder.setTitle(menuItitle); builder.setAdapter( menuAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialoginterface, int i) { IconContextMenuItem item = (IconContextMenuItem) menuAdapter.getItem(i); if (clickHandler != null) { clickHandler.onClick(item.actionTag); } } }); builder.setInverseBackgroundForced(true); AlertDialog dialog = builder.create(); dialog.setOnCancelListener(this); dialog.setOnDismissListener(this); return dialog; }
/** Showing alert dialog for hide or show option */ public void AlertDialogWindow( final String pStatus, final String commoditIds, final String vendorIds) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(true); builder.setTitle("Discard cart"); if (pStatus.equalsIgnoreCase("Hide")) { builder.setMessage("Are you sure you want to hide this commodity price to Consumer?"); } else { builder.setMessage("Are you sure you want to show this commodity price to Consumer?"); } builder.setInverseBackgroundForced(true); builder.setPositiveButton( "Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (pStatus.equalsIgnoreCase("Hide")) { } else { } } }); builder.setNegativeButton( "No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
protected Dialog onCreateDialog(int id) { Dialog dialog = null; AlertDialog.Builder builder = new AlertDialog.Builder(this); switch (id) { case ABOUT_DIALOG: builder.setTitle(R.string.about_button); builder.setMessage(R.string.about_text); builder.setPositiveButton( R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { return; } }); builder.setNeutralButton( getText(R.string.feedback), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra( android.content.Intent.EXTRA_EMAIL, new String[] {getString(R.string.send_feedback_email_emailaddress)}); emailIntent.putExtra( android.content.Intent.EXTRA_SUBJECT, getText(R.string.send_feedback_email_title)); startActivity(Intent.createChooser(emailIntent, getText(R.string.send_email))); } }); dialog = builder.create(); break; case LOGIN_FAILED: builder.setTitle(R.string.login_failed); builder.setMessage(R.string.login_failed_text); builder.setPositiveButton( R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { return; } }); dialog = builder.create(); break; case CONNECTION_FAILED: builder.setTitle(R.string.connection_failed); builder.setMessage(R.string.connection_failed_text); builder.setCancelable(true); builder.setInverseBackgroundForced(true); builder.setPositiveButton( R.string.ok, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); dialog = builder.create(); break; default: dialog = null; } return dialog; }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { /** * *********************************************** 步骤3:处理银联手机支付控件返回的支付结果 * ********************************************** */ if (data == null) { return; } String msg = ""; /* * 支付控件返回字符串:success、fail、cancel 分别代表支付成功,支付失败,支付取消 */ String str = data.getExtras().getString("pay_result"); if (str.equalsIgnoreCase("success")) { // 支付成功后,extra中如果存在result_data,取出校验 // result_data结构见c)result_data参数说明 if (data.hasExtra("result_data")) { String result = data.getExtras().getString("result_data"); try { JSONObject resultJson = new JSONObject(result); String sign = resultJson.getString("sign"); String dataOrg = resultJson.getString("data"); // 验签证书同后台验签证书 // 此处的verify,商户需送去商户后台做验签 boolean ret = RSAUtil.verify(dataOrg, sign, mode); if (ret) { // 验证通过后,显示支付结果 msg = "支付成功!"; } else { // 验证不通过后的处理 // 建议通过商户后台查询支付结果 msg = "支付失败!"; } } catch (JSONException e) { } } else { // 未收到签名信息 // 建议通过商户后台查询支付结果 msg = "支付成功!"; } } else if (str.equalsIgnoreCase("fail")) { msg = "支付失败!"; } else if (str.equalsIgnoreCase("cancel")) { msg = "用户取消了支付"; } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("支付结果通知"); builder.setMessage(msg); builder.setInverseBackgroundForced(true); // builder.setCustomTitle(); builder.setNegativeButton( "确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); }
public void show( String aTitle, String aText, PromptButton[] aButtons, PromptListItem[] aMenuList, boolean aMultipleSelection) { final GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient(); layerClient.post( new Runnable() { public void run() { // treat actions that show a dialog as if preventDefault by content to prevent panning layerClient.getPanZoomController().abortPanning(); } }); AlertDialog.Builder builder = new AlertDialog.Builder(GeckoApp.mAppContext); if (!aTitle.equals("")) { builder.setTitle(aTitle); } if (!aText.equals("")) { builder.setMessage(aText); } int length = mInputs == null ? 0 : mInputs.length; if (aMenuList != null && aMenuList.length > 0) { int resourceId = android.R.layout.select_dialog_item; if (mSelected != null && mSelected.length > 0) { if (aMultipleSelection) { resourceId = android.R.layout.select_dialog_multichoice; } else { resourceId = android.R.layout.select_dialog_singlechoice; } } PromptListAdapter adapter = new PromptListAdapter(GeckoApp.mAppContext, resourceId, aMenuList); if (mSelected != null && mSelected.length > 0) { if (aMultipleSelection) { adapter.listView = (ListView) mInflater.inflate(R.layout.select_dialog_list, null); adapter.listView.setOnItemClickListener(this); builder.setInverseBackgroundForced(true); adapter.listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); adapter.listView.setAdapter(adapter); builder.setView(adapter.listView); } else { int selectedIndex = -1; for (int i = 0; i < mSelected.length; i++) { if (mSelected[i]) { selectedIndex = i; break; } } mSelected = null; builder.setSingleChoiceItems(adapter, selectedIndex, this); } } else { builder.setAdapter(adapter, this); mSelected = null; } } else if (length == 1) { builder.setView(mInputs[0].getView()); } else if (length > 1) { LinearLayout linearLayout = new LinearLayout(GeckoApp.mAppContext); linearLayout.setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < length; i++) { View content = mInputs[i].getView(); linearLayout.addView(content); } builder.setView((View) linearLayout); } length = aButtons == null ? 0 : aButtons.length; if (length > 0) { builder.setPositiveButton(aButtons[0].label, this); } if (length > 1) { builder.setNeutralButton(aButtons[1].label, this); } if (length > 2) { builder.setNegativeButton(aButtons[2].label, this); } mDialog = builder.create(); mDialog.setOnCancelListener(this); mDialog.show(); }
public void show( String aTitle, String aText, PromptListItem[] aMenuList, boolean aMultipleSelection) { ThreadUtils.assertOnUiThread(); // treat actions that show a dialog as if preventDefault by content to prevent panning GeckoApp.mAppContext.getLayerView().abortPanning(); AlertDialog.Builder builder = new AlertDialog.Builder(GeckoApp.mAppContext); if (!TextUtils.isEmpty(aTitle)) { builder.setTitle(aTitle); } if (!TextUtils.isEmpty(aText)) { builder.setMessage(aText); } int length = mInputs == null ? 0 : mInputs.length; if (aMenuList != null && aMenuList.length > 0) { int resourceId = android.R.layout.simple_list_item_1; if (mSelected != null && mSelected.length > 0) { if (aMultipleSelection) { resourceId = R.layout.select_dialog_multichoice; } else { resourceId = R.layout.select_dialog_singlechoice; } } PromptListAdapter adapter = new PromptListAdapter(GeckoApp.mAppContext, resourceId, aMenuList); if (mSelected != null && mSelected.length > 0) { if (aMultipleSelection) { adapter.listView = (ListView) mInflater.inflate(R.layout.select_dialog_list, null); adapter.listView.setOnItemClickListener(this); builder.setInverseBackgroundForced(true); adapter.listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); adapter.listView.setAdapter(adapter); builder.setView(adapter.listView); } else { int selectedIndex = -1; for (int i = 0; i < mSelected.length; i++) { if (mSelected[i]) { selectedIndex = i; break; } } mSelected = null; builder.setSingleChoiceItems(adapter, selectedIndex, this); } } else { builder.setAdapter(adapter, this); mSelected = null; } } else if (length == 1) { try { ScrollView view = new ScrollView(GeckoApp.mAppContext); view.addView(mInputs[0].getView()); builder.setView(applyInputStyle(view)); } catch (UnsupportedOperationException ex) { // We cannot display these input widgets with this sdk version, // do not display any dialog and finish the prompt now. finishDialog("{\"button\": -1}"); return; } } else if (length > 1) { try { LinearLayout linearLayout = new LinearLayout(GeckoApp.mAppContext); linearLayout.setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < length; i++) { View content = mInputs[i].getView(); linearLayout.addView(content); } ScrollView view = new ScrollView(GeckoApp.mAppContext); view.addView(linearLayout); builder.setView(applyInputStyle(view)); } catch (UnsupportedOperationException ex) { // We cannot display these input widgets with this sdk version, // do not display any dialog and finish the prompt now. finishDialog("{\"button\": -1}"); return; } } length = mButtons == null ? 0 : mButtons.length; if (length > 0) { builder.setPositiveButton(mButtons[0], this); if (length > 1) { builder.setNeutralButton(mButtons[1], this); if (length > 2) { builder.setNegativeButton(mButtons[2], this); } } } mDialog = builder.create(); mDialog.setOnCancelListener(PromptService.this); mDialog.show(); }
@SuppressWarnings("deprecation") public void onClick(View v) { AlertDialog.Builder alert = new AlertDialog.Builder( Sos_ReservingInSelectSpace.this.getParent().getParent().getParent()); alert.setInverseBackgroundForced(true); alert.setTitle("알림"); alert.setMessage("B011128 학번으로 K204호에서\n8월 20일 7~8:30 시에 예약하시겠습니까?"); alert.setCancelable(false); Log.d("check", "is OK"); alert.setIcon(R.drawable.ic_launcher); alert.setPositiveButton( "예", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Log.d("check : ", "#5"); Intent intent = new Intent( Sos_ReservingInSelectSpace.this, com.hongikapp.utility.sos.reserved.Sos_Reserved_main.class); com.hongikapp.utility.sos.reserved.Sos_TabHost_Reserved.Reserved_Group .replaceView( com.hongikapp.utility.sos.reserved.Sos_TabHost_Reserved.Reserved_Group .getLocalActivityManager() .startActivity( "Utility_Sos", intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)) .getDecorView()); Log.d("check", "is OK"); } }); /* * startActivity(new Intent( Sos_ReservingInSelectSpace.this, * com.hongikapp.utility .sos.reserved.Sos_TabHost_Reserved.class) * .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | * Intent.FLAG_ACTIVITY_SINGLE_TOP)); } }); */ alert.setNegativeButton( "아니오", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { /* * startActivity(new Intent( * Sos_ReservingInSelectSpace.this, * Sos_ReservingInSelectTime_Main.class) . * addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | * Intent.FLAG_ACTIVITY_SINGLE_TOP)); */ Intent intent = new Intent( Sos_ReservingInSelectSpace.this, Sos_ReservingInSelectTime_Main.class); Sos_TabHost_ReservingIn.ReservingIn_Group.replaceView( Sos_TabHost_ReservingIn.ReservingIn_Group.getLocalActivityManager() .startActivity( "Utility_Sos", intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)) .getDecorView()); } }); Log.d("check", "is OK?????"); alert.show(); Log.d("check", "is OK..............."); }
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); exchangeCurrency = prefs.getString(Constants.PREFS_KEY_EXCHANGE_CURRENCY, Constants.DEFAULT_EXCHANGE_CURRENCY); final AlertDialog.Builder dialog = new AlertDialog.Builder(activity); dialog.setInverseBackgroundForced(true); dialog.setTitle(R.string.amount_calculator_dialog_title); final View view = inflater.inflate(R.layout.amount_calculator_dialog, null); btcAmountView = (CurrencyAmountView) view.findViewById(R.id.amount_calculator_row_btc); btcAmountView.setListener( new CurrencyAmountView.Listener() { public void changed() { if (btcAmountView.getAmount() != null) { exchangeDirection = true; updateAppearance(); } else { localAmountView.setHint(null); } } public void done() { AmountCalculatorFragment.this.done(); } public void focusChanged(final boolean hasFocus) {} }); localAmountView = (CurrencyAmountView) view.findViewById(R.id.amount_calculator_row_local); localAmountView.setCurrencyCode(exchangeCurrency); localAmountView.setListener( new CurrencyAmountView.Listener() { public void changed() { if (localAmountView.getAmount() != null) { exchangeDirection = false; updateAppearance(); } else { btcAmountView.setHint(null); } } public void done() { AmountCalculatorFragment.this.done(); } public void focusChanged(final boolean hasFocus) {} }); exchangeRateView = (TextView) view.findViewById(R.id.amount_calculator_rate); dialog.setView(view); dialog.setPositiveButton( R.string.amount_calculator_dialog_button_use, new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int whichButton) { done(); } }); dialog.setNegativeButton( R.string.button_cancel, new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int whichButton) { dismiss(); } }); updateAppearance(); getLoaderManager().initLoader(0, null, this); return dialog.create(); }