List of usage examples for android.app AlertDialog setButton
@Deprecated public void setButton(CharSequence text, final OnClickListener listener)
From source file:sssemil.com.hostsaway.ui.RedirectionListFragment.java
/** * Add new entry based on input/*ww w . ja v a 2s . c o m*/ * * @param input */ private void addEntry(String hostname, String ip) { if (hostname != null) { if (RegexUtils.isValidHostname(hostname)) { if (RegexUtils.isValidIP(ip)) { ProviderHelper.insertRedirectionListItem(mActivity, hostname, ip); } else { AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_alert); alertDialog.setTitle(R.string.no_ip_title); alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_ip)); alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sum) { dlg.dismiss(); } }); alertDialog.show(); } } else { AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_alert); alertDialog.setTitle(R.string.no_hostname_title); alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_hostname)); alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sum) { dlg.dismiss(); } }); alertDialog.show(); } } }
From source file:cm.aptoide.pt.RemoteInTab.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == NEWREPO_FLAG) { if (data != null && data.hasExtra("update")) { final AlertDialog alrt = new AlertDialog.Builder(this).create(); alrt.setTitle("Update repositories"); alrt.setMessage("The list of repositories in use has been changed.\nDo you wish to update them?"); alrt.setButton("Yes", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { updateRepos();/*www .j av a2 s. c om*/ } }); alrt.setButton2("No", new OnClickListener() { public void onClick(DialogInterface dialog, int which) { alrt.dismiss(); } }); alrt.show(); } } else if (requestCode == SETTINGS_FLAG) { if (data != null && data.hasExtra("align")) { order_lst = data.getExtras().getString("align"); prefEdit.putString("order_lst", order_lst); prefEdit.commit(); } } }
From source file:org.adawaycn.ui.HostsSourcesFragment.java
/** * Edit entry based on selection in context menu * * @param info//from w ww .j a va2 s . c o m */ private void menuEditEntry(AdapterContextMenuInfo info) { mCurrentRowId = info.id; // set global RowId to row id from cursor to use inside save button int position = info.position; View v = info.targetView; TextView urlTextView = (TextView) v.findViewWithTag("url_" + position); AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); builder.setCancelable(true); builder.setTitle(getString(R.string.checkbox_list_edit_dialog_title)); // build view from layout LayoutInflater factory = LayoutInflater.from(mActivity); final View dialogView = factory.inflate(R.layout.lists_url_dialog, null); final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_url); // set text from list inputEditText.setText(urlTextView.getText()); inputEditText.setInputType(InputType.TYPE_TEXT_VARIATION_URI); // move cursor to end of EditText Editable inputEditContent = inputEditText.getText(); inputEditText.setSelection(inputEditContent.length()); builder.setView(dialogView); builder.setPositiveButton(getResources().getString(R.string.button_save), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); String input = inputEditText.getText().toString(); if (RegexUtils.isValidUrl(input)) { // update in db ProviderHelper.updateHostsSourceUrl(mActivity, mCurrentRowId, input); } else { AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_alert); alertDialog.setTitle(R.string.no_url_title); alertDialog.setMessage(getString(R.string.no_url)); alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sum) { dlg.dismiss(); } }); alertDialog.show(); } } }); builder.setNegativeButton(getResources().getString(R.string.button_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:org.adawaycn.ui.WhitelistFragment.java
/** * Edit entry based on selection in context menu * * @param info// ww w .jav a 2 s .c om */ private void menuEditEntry(AdapterContextMenuInfo info) { mCurrentRowId = info.id; // set global RowId to row id from cursor to use inside save button int position = info.position; View v = info.targetView; CheckBox cBox = (CheckBox) v.findViewWithTag(position); AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); builder.setCancelable(true); builder.setTitle(getString(R.string.checkbox_list_edit_dialog_title)); // build view from layout LayoutInflater factory = LayoutInflater.from(mActivity); final View dialogView = factory.inflate(R.layout.lists_whitelist_hostname_dialog, null); final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_hostname); inputEditText.setText(cBox.getText()); // move cursor to end of EditText Editable inputEditContent = inputEditText.getText(); inputEditText.setSelection(inputEditContent.length()); builder.setView(dialogView); builder.setPositiveButton(getResources().getString(R.string.button_save), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); String input = inputEditText.getText().toString(); if (RegexUtils.isValidWhitelistHostname(input)) { ProviderHelper.updateWhitelistItemHostname(mActivity, mCurrentRowId, input); } else { AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_alert); alertDialog.setTitle(R.string.no_hostname_title); alertDialog.setMessage(getString(R.string.no_hostname)); alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sum) { dlg.dismiss(); } }); alertDialog.show(); } } }); builder.setNegativeButton(getResources().getString(R.string.button_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:org.adawaycn.ui.BlacklistFragment.java
/** * Edit entry based on selection in context menu * /*from w w w . j a va 2 s. c o m*/ * @param info */ private void menuEditEntry(AdapterContextMenuInfo info) { mCurrentRowId = info.id; // set global RowId to row id from cursor to use inside save button int position = info.position; View v = info.targetView; CheckBox cBox = (CheckBox) v.findViewWithTag(position); AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); builder.setCancelable(true); builder.setTitle(getString(R.string.checkbox_list_edit_dialog_title)); // build view from layout LayoutInflater factory = LayoutInflater.from(mActivity); final View dialogView = factory.inflate(R.layout.lists_hostname_dialog, null); final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_hostname); inputEditText.setText(cBox.getText()); // move cursor to end of EditText Editable inputEditContent = inputEditText.getText(); inputEditText.setSelection(inputEditContent.length()); builder.setView(dialogView); builder.setPositiveButton(getResources().getString(R.string.button_save), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); String input = inputEditText.getText().toString(); if (org.adawaycn.util.RegexUtils.isValidHostname(input)) { org.adawaycn.provider.ProviderHelper.updateBlacklistItemHostname(mActivity, mCurrentRowId, input); } else { AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_alert); alertDialog.setTitle(R.string.no_hostname_title); alertDialog.setMessage(getString(R.string.no_hostname)); alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sum) { dlg.dismiss(); } }); alertDialog.show(); } } }); builder.setNegativeButton(getResources().getString(R.string.button_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.aknowledge.v1.automation.RemoteActivity.java
public void onDevicesLoaded(String result) { Log.d("RemoteActivity", "devices loaded: " + result); if (dialog != null && dialog.isShowing()) { dialog.dismiss();/*from www . j av a 2 s . co m*/ } if (result != null) { parseMyDevices(result); createRemotePanel(); } else { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("Problems with your server info."); alertDialog.setMessage("You should check your settings and try again."); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); // Set the Icon for the Dialog alertDialog.show(); } }
From source file:org.adaway.ui.BlacklistFragment.java
/** * Edit entry based on selection in context menu * //from w ww . ja v a2 s . c o m * @param info */ private void menuEditEntry(AdapterContextMenuInfo info) { mCurrentRowId = info.id; // set global RowId to row id from cursor to use inside save button int position = info.position; View v = info.targetView; CheckBox cBox = (CheckBox) v.findViewWithTag(position); AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); builder.setCancelable(true); builder.setTitle(getString(R.string.checkbox_list_edit_dialog_title)); // build view from layout LayoutInflater factory = LayoutInflater.from(mActivity); final View dialogView = factory.inflate(R.layout.lists_hostname_dialog, null); final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_hostname); inputEditText.setText(cBox.getText()); // move cursor to end of EditText Editable inputEditContent = inputEditText.getText(); inputEditText.setSelection(inputEditContent.length()); builder.setView(dialogView); builder.setPositiveButton(getResources().getString(R.string.button_save), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); String input = inputEditText.getText().toString(); if (RegexUtils.isValidHostname(input)) { ProviderHelper.updateBlacklistItemHostname(mActivity, mCurrentRowId, input); } else { AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_alert); alertDialog.setTitle(R.string.no_hostname_title); alertDialog.setMessage(getString(org.adaway.R.string.no_hostname)); alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sum) { dlg.dismiss(); } }); alertDialog.show(); } } }); builder.setNegativeButton(getResources().getString(R.string.button_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:org.adaway.ui.HostsSourcesFragment.java
/** * Edit entry based on selection in context menu * * @param info/*w w w . java2 s .c o m*/ */ private void menuEditEntry(AdapterContextMenuInfo info) { mCurrentRowId = info.id; // set global RowId to row id from cursor to use inside save button int position = info.position; View v = info.targetView; TextView urlTextView = (TextView) v.findViewWithTag("url_" + position); AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); builder.setCancelable(true); builder.setTitle(getString(R.string.checkbox_list_edit_dialog_title)); // build view from layout LayoutInflater factory = LayoutInflater.from(mActivity); final View dialogView = factory.inflate(R.layout.lists_url_dialog, null); final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_url); // set text from list inputEditText.setText(urlTextView.getText()); inputEditText.setInputType(InputType.TYPE_TEXT_VARIATION_URI); // move cursor to end of EditText Editable inputEditContent = inputEditText.getText(); inputEditText.setSelection(inputEditContent.length()); builder.setView(dialogView); builder.setPositiveButton(getResources().getString(R.string.button_save), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); String input = inputEditText.getText().toString(); if (RegexUtils.isValidUrl(input)) { // update in db ProviderHelper.updateHostsSourceUrl(mActivity, mCurrentRowId, input); } else { AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_alert); alertDialog.setTitle(R.string.no_url_title); alertDialog.setMessage(getString(org.adaway.R.string.no_url)); alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sum) { dlg.dismiss(); } }); alertDialog.show(); } } }); builder.setNegativeButton(getResources().getString(R.string.button_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:org.adaway.ui.WhitelistFragment.java
/** * Edit entry based on selection in context menu * * @param info/*w w w .j a v a2 s. co m*/ */ private void menuEditEntry(AdapterContextMenuInfo info) { mCurrentRowId = info.id; // set global RowId to row id from cursor to use inside save button int position = info.position; View v = info.targetView; CheckBox cBox = (CheckBox) v.findViewWithTag(position); AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); builder.setCancelable(true); builder.setTitle(getString(R.string.checkbox_list_edit_dialog_title)); // build view from layout LayoutInflater factory = LayoutInflater.from(mActivity); final View dialogView = factory.inflate(R.layout.lists_whitelist_hostname_dialog, null); final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_hostname); inputEditText.setText(cBox.getText()); // move cursor to end of EditText Editable inputEditContent = inputEditText.getText(); inputEditText.setSelection(inputEditContent.length()); builder.setView(dialogView); builder.setPositiveButton(getResources().getString(R.string.button_save), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); String input = inputEditText.getText().toString(); if (RegexUtils.isValidWhitelistHostname(input)) { ProviderHelper.updateWhitelistItemHostname(mActivity, mCurrentRowId, input); } else { AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_alert); alertDialog.setTitle(R.string.no_hostname_title); alertDialog.setMessage(getString(org.adaway.R.string.no_hostname)); alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sum) { dlg.dismiss(); } }); alertDialog.show(); } } }); builder.setNegativeButton(getResources().getString(R.string.button_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:sssemil.com.hostsaway.ui.BlacklistFragment.java
/** * Edit entry based on selection in context menu * * @param info//w ww. j av a 2 s.co m */ private void menuEditEntry(AdapterContextMenuInfo info) { mCurrentRowId = info.id; // set global RowId to row id from cursor to use inside save button int position = info.position; View v = info.targetView; CheckBox cBox = (CheckBox) v.findViewWithTag(position); AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); builder.setCancelable(true); builder.setTitle(getString(R.string.checkbox_list_edit_dialog_title)); // build view from layout LayoutInflater factory = LayoutInflater.from(mActivity); final View dialogView = factory.inflate(R.layout.lists_hostname_dialog, null); final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_hostname); inputEditText.setText(cBox.getText()); // move cursor to end of EditText Editable inputEditContent = inputEditText.getText(); inputEditText.setSelection(inputEditContent.length()); builder.setView(dialogView); builder.setPositiveButton(getResources().getString(R.string.button_save), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); String input = inputEditText.getText().toString(); if (RegexUtils.isValidHostname(input)) { ProviderHelper.updateBlacklistItemHostname(mActivity, mCurrentRowId, input); } else { AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_alert); alertDialog.setTitle(R.string.no_hostname_title); alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_hostname)); alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sum) { dlg.dismiss(); } }); alertDialog.show(); } } }); builder.setNegativeButton(getResources().getString(R.string.button_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }