List of usage examples for android.app AlertDialog findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:org.awesomeapp.messenger.MainActivity.java
public void showGroupChatDialog() { // This example shows how to add a custom layout to an AlertDialog LayoutInflater factory = LayoutInflater.from(this); final View dialogGroup = factory.inflate(R.layout.alert_dialog_group_chat, null); //TextView tvServer = (TextView) dialogGroup.findViewById(R.id.chat_server); // tvServer.setText(ImApp.DEFAULT_GROUPCHAT_SERVER);// need to make this a list // final Spinner listAccounts = (Spinner) dialogGroup.findViewById(R.id.choose_list); // setupAccountSpinner(listAccounts); AlertDialog dialog = new AlertDialog.Builder(this).setTitle(R.string.create_group).setView(dialogGroup) .setPositiveButton(R.string.connect, new DialogInterface.OnClickListener() { @Override/* ww w . j a v a 2 s .c om*/ public void onClick(DialogInterface dialog, int whichButton) { /* User clicked OK so do some stuff */ String chatRoom = null; String chatServer = ""; String nickname = ""; TextView tv = (TextView) dialogGroup.findViewById(R.id.chat_room); chatRoom = tv.getText().toString(); /** tv = (TextView) dialogGroup.findViewById(R.id.chat_server); chatServer = tv.getText().toString(); tv = (TextView) dialogGroup.findViewById(R.id.nickname); nickname = tv.getText().toString(); **/ try { IImConnection conn = mApp.getConnection(mApp.getDefaultProviderId(), mApp.getDefaultAccountId()); if (conn.getState() == ImConnection.LOGGED_IN) startGroupChat(chatRoom, chatServer, nickname, null, conn); } catch (RemoteException re) { } dialog.dismiss(); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { /* User clicked cancel so do some stuff */ dialog.dismiss(); } }).create(); dialog.show(); Typeface typeface; if ((typeface = CustomTypefaceManager.getCurrentTypeface(this)) != null) { TextView textView = (TextView) dialog.findViewById(android.R.id.message); if (textView != null) textView.setTypeface(typeface); textView = (TextView) dialog.findViewById(R.id.alertTitle); if (textView != null) textView.setTypeface(typeface); Button btn = (Button) dialog.findViewById(android.R.id.button1); if (btn != null) btn.setTypeface(typeface); btn = (Button) dialog.findViewById(android.R.id.button2); if (btn != null) btn.setTypeface(typeface); btn = (Button) dialog.findViewById(android.R.id.button3); if (btn != null) btn.setTypeface(typeface); } }
From source file:com.kncwallet.wallet.ui.WalletActivity.java
private void prepareImportKeysDialog(final Dialog dialog) { final AlertDialog alertDialog = (AlertDialog) dialog; final List<File> files = new LinkedList<File>(); // external storage if (Constants.EXTERNAL_WALLET_BACKUP_DIR.exists() && Constants.EXTERNAL_WALLET_BACKUP_DIR.isDirectory()) for (final File file : Constants.EXTERNAL_WALLET_BACKUP_DIR.listFiles()) if (WalletUtils.KEYS_FILE_FILTER.accept(file) || Crypto.OPENSSL_FILE_FILTER.accept(file)) files.add(file);/*from w w w. j a v a2s . co m*/ // internal storage for (final String filename : fileList()) if (filename.startsWith(Constants.WALLET_KEY_BACKUP_BASE58 + '.')) files.add(new File(getFilesDir(), filename)); // sort Collections.sort(files, new Comparator<File>() { @Override public int compare(final File lhs, final File rhs) { return lhs.getName().compareToIgnoreCase(rhs.getName()); } }); final FileAdapter adapter = new FileAdapter(this, files) { @Override public View getDropDownView(final int position, View row, final ViewGroup parent) { final File file = getItem(position); final boolean isExternal = Constants.EXTERNAL_WALLET_BACKUP_DIR.equals(file.getParentFile()); final boolean isEncrypted = Crypto.OPENSSL_FILE_FILTER.accept(file); if (row == null) row = inflater.inflate(R.layout.wallet_import_keys_file_row, null); final TextView filenameView = (TextView) row .findViewById(R.id.wallet_import_keys_file_row_filename); filenameView.setText(file.getName()); final TextView securityView = (TextView) row .findViewById(R.id.wallet_import_keys_file_row_security); final String encryptedStr = context .getString(isEncrypted ? R.string.import_keys_dialog_file_security_encrypted : R.string.import_keys_dialog_file_security_unencrypted); final String storageStr = context .getString(isExternal ? R.string.import_keys_dialog_file_security_external : R.string.import_keys_dialog_file_security_internal); securityView.setText(encryptedStr + ", " + storageStr); final TextView createdView = (TextView) row.findViewById(R.id.wallet_import_keys_file_row_created); createdView.setText(context.getString( isExternal ? R.string.import_keys_dialog_file_created_manual : R.string.import_keys_dialog_file_created_automatic, DateUtils.getRelativeTimeSpanString(context, file.lastModified(), true))); return row; } }; final Spinner fileView = (Spinner) alertDialog.findViewById(R.id.import_keys_from_storage_file); fileView.setAdapter(adapter); fileView.setEnabled(!adapter.isEmpty()); final EditText passwordView = (EditText) alertDialog.findViewById(R.id.import_keys_from_storage_password); passwordView.setText(null); final ImportDialogButtonEnablerListener dialogButtonEnabler = new ImportDialogButtonEnablerListener( passwordView, alertDialog) { @Override protected boolean hasFile() { return fileView.getSelectedItem() != null; } @Override protected boolean needsPassword() { final File selectedFile = (File) fileView.getSelectedItem(); return selectedFile != null ? Crypto.OPENSSL_FILE_FILTER.accept(selectedFile) : false; } }; passwordView.addTextChangedListener(dialogButtonEnabler); fileView.setOnItemSelectedListener(dialogButtonEnabler); final CheckBox showView = (CheckBox) alertDialog.findViewById(R.id.import_keys_from_storage_show); showView.setOnCheckedChangeListener(new ShowPasswordCheckListener(passwordView)); KnCDialog.fixDialogDivider(alertDialog); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptMachineName(final Activity activity) { final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Machine Name"); EditText searchView = new EditText(activity); searchView.setEnabled(true);//from ww w . j a va2s. c o m searchView.setVisibility(View.VISIBLE); searchView.setId(201012010); searchView.setSingleLine(); alertDialog.setView(searchView); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // UIUtils.log("Searching..."); EditText a = (EditText) alertDialog.findViewById(201012010); sendHandlerMessage(handler, Const.VM_CREATED, "machine_name", a.getText().toString()); return; } }); alertDialog.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptStateName(final Activity activity) { final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Snapshot/State Name"); EditText searchView = new EditText(activity); searchView.setEnabled(true);//from w ww . j a v a 2 s . com searchView.setVisibility(View.VISIBLE); searchView.setId(201012010); searchView.setSingleLine(); alertDialog.setView(searchView); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // UIUtils.log("Searching..."); EditText a = (EditText) alertDialog.findViewById(201012010); sendHandlerMessage(handler, Const.SNAPSHOT_CREATED, new String[] { "snapshot_name" }, new String[] { a.getText().toString() }); return; } }); alertDialog.show(); }
From source file:mobi.omegacentauri.ptimer.PTimerEditActivity.java
void showServerPrompt(final boolean userInitiated) { final SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE); final SpannableString message = new SpannableString(getResources().getText(R.string.server_prompt)); Linkify.addLinks(message, Linkify.ALL); final AlertDialog dialog = new AlertDialog.Builder(PTimerEditActivity.this).setTitle(R.string.server_title) .setMessage(message).setPositiveButton(R.string.server_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { SharedPreferences.Editor prefsEditor = prefs.edit(); prefsEditor.putInt(PREF_STATS_SERVER_ALLOWED, SERVER_ALLOWED_YES); prefsEditor.commit(); if (userInitiated) { finish();/*w ww.j a va 2 s. c om*/ } else { sendStatsToServerAndFinish(); } } }).setNeutralButton(R.string.server_later, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { int allowServerCheckIndex = prefs.getInt(PREF_STATS_SERVER_CHECK, 2); int successCount = prefs.getInt(PREF_SUCCESS_COUNT, 0); SharedPreferences.Editor prefsEditor = prefs.edit(); if (userInitiated) { prefsEditor.putInt(PREF_STATS_SERVER_CHECK, successCount + 2); } else { prefsEditor.putInt(PREF_STATS_SERVER_CHECK, allowServerCheckIndex * 2); } prefsEditor.commit(); finish(); } }).setNegativeButton(R.string.server_never, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { SharedPreferences.Editor prefsEditor = prefs.edit(); prefsEditor.putInt(PREF_STATS_SERVER_ALLOWED, SERVER_ALLOWED_NO); if (userInitiated) { // If the user initiated, err on the safe side and disable // sending crash reports too. There's no way to turn them // back on now aside from clearing data from this app, but // it doesn't matter, we don't need error reports from every // user ever. prefsEditor.putInt(PREF_ERR_SERVER_ALLOWED, SERVER_ALLOWED_NO); } prefsEditor.commit(); finish(); } }).setCancelable(false).show(); // Make links clicky ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.SpeechEd.SpeechEdEditActivity.java
void showServerPrompt(final boolean userInitiated) { final SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE); final SpannableString message = new SpannableString(getResources().getText(R.string.server_prompt)); Linkify.addLinks(message, Linkify.ALL); final AlertDialog dialog = new AlertDialog.Builder(SpeechEdEditActivity.this) .setTitle(R.string.server_title).setMessage(message) .setPositiveButton(R.string.server_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { SharedPreferences.Editor prefsEditor = prefs.edit(); prefsEditor.putInt(PREF_STATS_SERVER_ALLOWED, SERVER_ALLOWED_YES); prefsEditor.commit(); if (userInitiated) { finish();// w w w .ja v a 2 s . c om } else { sendStatsToServerAndFinish(); } } }).setNeutralButton(R.string.server_later, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { int allowServerCheckIndex = prefs.getInt(PREF_STATS_SERVER_CHECK, 2); int successCount = prefs.getInt(PREF_SUCCESS_COUNT, 0); SharedPreferences.Editor prefsEditor = prefs.edit(); if (userInitiated) { prefsEditor.putInt(PREF_STATS_SERVER_CHECK, successCount + 2); } else { prefsEditor.putInt(PREF_STATS_SERVER_CHECK, allowServerCheckIndex * 2); } prefsEditor.commit(); finish(); } }).setNegativeButton(R.string.server_never, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { SharedPreferences.Editor prefsEditor = prefs.edit(); prefsEditor.putInt(PREF_STATS_SERVER_ALLOWED, SERVER_ALLOWED_NO); if (userInitiated) { // If the user initiated, err on the safe side and disable // sending crash reports too. There's no way to turn them // back on now aside from clearing data from this app, but // it doesn't matter, we don't need error reports from every // user ever. prefsEditor.putInt(PREF_ERR_SERVER_ALLOWED, SERVER_ALLOWED_NO); } prefsEditor.commit(); finish(); } }).setCancelable(false).show(); // Make links clicky ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.Beat.RingdroidEditActivity.java
void showServerPrompt(final boolean userInitiated) { final SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE); final SpannableString message = new SpannableString(getResources().getText(R.string.server_prompt)); Linkify.addLinks(message, Linkify.ALL); final AlertDialog dialog = new AlertDialog.Builder(RingdroidEditActivity.this) .setTitle(R.string.server_title).setMessage(message) .setPositiveButton(R.string.server_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { SharedPreferences.Editor prefsEditor = prefs.edit(); prefsEditor.putInt(PREF_STATS_SERVER_ALLOWED, SERVER_ALLOWED_YES); prefsEditor.commit(); if (userInitiated) { finish();//from w w w . ja v a 2 s. c o m } else { sendStatsToServerAndFinish(); } } }).setNeutralButton(R.string.server_later, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { int allowServerCheckIndex = prefs.getInt(PREF_STATS_SERVER_CHECK, 2); int successCount = prefs.getInt(PREF_SUCCESS_COUNT, 0); SharedPreferences.Editor prefsEditor = prefs.edit(); if (userInitiated) { prefsEditor.putInt(PREF_STATS_SERVER_CHECK, successCount + 2); } else { prefsEditor.putInt(PREF_STATS_SERVER_CHECK, allowServerCheckIndex * 2); } prefsEditor.commit(); finish(); } }).setNegativeButton(R.string.server_never, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { SharedPreferences.Editor prefsEditor = prefs.edit(); prefsEditor.putInt(PREF_STATS_SERVER_ALLOWED, SERVER_ALLOWED_NO); if (userInitiated) { // If the user initiated, err on the safe side and disable // sending crash reports too. There's no way to turn them // back on now aside from clearing data from this app, but // it doesn't matter, we don't need error reports from every // user ever. prefsEditor.putInt(PREF_ERR_SERVER_ALLOWED, SERVER_ALLOWED_NO); } prefsEditor.commit(); finish(); } }).setCancelable(false).show(); // Make links clicky ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:org.tvbrowser.tvbrowser.TvBrowser.java
private void showUserSetting(final String initiateUserName, final String initiatePassword, final boolean syncChannels) { AlertDialog.Builder builder = new AlertDialog.Builder(TvBrowser.this); builder.setCancelable(false);/*from ww w . j a va 2 s. c o m*/ RelativeLayout username_password_setup = (RelativeLayout) getLayoutInflater() .inflate(R.layout.username_password_setup, getParentViewGroup(), false); final SharedPreferences pref = getSharedPreferences("transportation", Context.MODE_PRIVATE); final EditText userName = (EditText) username_password_setup.findViewById(R.id.username_entry); final EditText password = (EditText) username_password_setup.findViewById(R.id.password_entry); userName.setText( pref.getString(SettingConstants.USER_NAME, initiateUserName != null ? initiateUserName : "")); password.setText( pref.getString(SettingConstants.USER_PASSWORD, initiatePassword != null ? initiatePassword : "")); builder.setView(username_password_setup); builder.setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setUserName(userName.getText().toString().trim(), password.getText().toString().trim(), syncChannels); } }); builder.setNegativeButton(android.R.string.cancel, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (syncChannels) { handler.post(new Runnable() { @Override public void run() { showChannelSelectionInternal(); } }); } } }); AlertDialog d = builder.create(); d.show(); ((TextView) d.findViewById(R.id.user_pw_sync_info)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:org.tvbrowser.tvbrowser.TvBrowser.java
private void checkTermsAccepted() { final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); String terms = pref.getString(SettingConstants.TERMS_ACCEPTED, ""); if (terms.contains("EPG_FREE")) { updateTvData();/*w w w . j av a 2 s .com*/ } else { AlertDialog.Builder builder = new AlertDialog.Builder(TvBrowser.this); builder.setTitle(R.string.terms_of_use_data); builder.setMessage(R.string.terms_of_use_text); builder.setPositiveButton(R.string.terms_of_use_accept, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Editor edit = pref.edit(); edit.putString(SettingConstants.TERMS_ACCEPTED, "EPG_FREE"); edit.commit(); updateTvData(); } }); builder.setNegativeButton(android.R.string.cancel, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); AlertDialog d = builder.create(); d.show(); ((TextView) d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); } }