Java Code Examples for android.support.v7.widget.AppCompatEditText#setHint()
The following examples show how to use
android.support.v7.widget.AppCompatEditText#setHint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From KA27 with Apache License 2.0 | 6 votes |
/** * Dialog which asks the user to enter his password * * @param password current encoded password */ private void askPassword(final String password) { LinearLayout linearLayout = new LinearLayout(this); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setGravity(Gravity.CENTER); linearLayout.setPadding(30, 20, 30, 20); final AppCompatEditText mPassword = new AppCompatEditText(this); mPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); mPassword.setHint(getString(R.string.password)); linearLayout.addView(mPassword); new AlertDialog.Builder(this).setView(linearLayout).setCancelable(false) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (mPassword.getText().toString().equals(Utils.decodeString(password))) new Task().execute(); else { Utils.toast(getString(R.string.password_wrong), MainActivity.this); finish(); } } }).show(); }
Example 2
Source File: MainActivity.java From kernel_adiutor with Apache License 2.0 | 6 votes |
/** * Dialog which asks the user to enter his password * * @param password current encoded password */ private void askPassword(final String password) { LinearLayout linearLayout = new LinearLayout(this); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setGravity(Gravity.CENTER); linearLayout.setPadding(30, 20, 30, 20); final AppCompatEditText mPassword = new AppCompatEditText(this); mPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); mPassword.setHint(getString(R.string.password)); linearLayout.addView(mPassword); new AlertDialog.Builder(this).setView(linearLayout).setCancelable(false) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (mPassword.getText().toString().equals(Utils.decodeString(password))) new Task().execute(); else { Utils.toast(getString(R.string.password_wrong), MainActivity.this); finish(); } } }).show(); }
Example 3
Source File: EditTextDialog.java From Cornowser with MIT License | 6 votes |
private void init() { mEditText = (AppCompatEditText) LayoutInflater.from(getContext()).inflate(R.layout.widget_ac_edittext_xquid, null); mEditText.setSingleLine(); if(!mTitle.isEmpty()) mEditText.setHint(mTitle); if(!mTitle.isEmpty()) mEditText.getEditableText().insert(0, mDefaultText); mEditText.setHighlightColor(ContextCompat.getColor(getContext(), R.color.blue_600)); mEditText.setTextColor(Color.BLACK); onClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }; }
Example 4
Source File: BaseDialog.java From TestChat with Apache License 2.0 | 5 votes |
/** * 设置编辑列表VIEW * * @param names 编辑view 的name * @return this */ public BaseDialog setEditViewsName(List<String> names) { if (middleLayout.getChildCount() > 0) { middleLayout.removeAllViews(); } for (String name : names) { TextView textView = new TextView(getContext()); textView.setText(name); textView.setTextColor(getContext().getResources().getColor(R.color.base_color_text_black)); AppCompatEditText editText = new AppCompatEditText(getContext(),null, android.R.attr.editTextStyle); editText.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); editText.setHint("请输入" + name); editText.setPadding(10, 0, 0, 0); editText.setHintTextColor(Color.BLUE); LinearLayout child = new LinearLayout(getContext()); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); child.setOrientation(LinearLayout.HORIZONTAL); child.setGravity(Gravity.CENTER_VERTICAL); child.setLayoutParams(params); child.addView(textView); child.addView(editText); middleLayout.addView(child); } return this; }
Example 5
Source File: FragmentMatrixInput.java From ncalc with GNU General Public License v3.0 | 5 votes |
private void createLayoutMatrix(int col, int row, ViewGroup viewGroup) { viewGroup.removeAllViews(); @IdRes int index = 1; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { AppCompatEditText editText = new AppCompatEditText(getContext()); editText.setHint("[" + i + "," + j + "]"); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); editText.setSingleLine(true); editText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL); editText.setId(index); if (isDebug) { editText.setText(String.valueOf(random.nextInt(200) - 100)); } if (j == 0) { params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE); } else { params.addRule(RelativeLayout.RIGHT_OF, index - 1); } if (i == 0) { params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE); } else { params.addRule(RelativeLayout.BELOW, index - col); } editText.setLayoutParams(params); viewGroup.addView(editText); index++; } } }
Example 6
Source File: SettingsFragment.java From KA27 with Apache License 2.0 | 5 votes |
private void deletePasswordDialog(final String password) { if (password.isEmpty()) { Utils.toast(getString(R.string.set_password_first), getActivity()); return; } LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setGravity(Gravity.CENTER); linearLayout.setPadding(30, 20, 30, 20); final AppCompatEditText mPassword = new AppCompatEditText(getActivity()); mPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); mPassword.setHint(getString(R.string.password)); linearLayout.addView(mPassword); new AlertDialog.Builder(getActivity(), (Utils.DARKTHEME ? R.style.AlertDialogStyleDark : R.style.AlertDialogStyleLight)).setView(linearLayout) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (!mPassword.getText().toString().equals(Utils.decodeString(password))) { Utils.toast(getString(R.string.password_wrong), getActivity()); return; } Utils.saveString("password", "", getActivity()); } }).show(); }
Example 7
Source File: SettingsFragment.java From kernel_adiutor with Apache License 2.0 | 5 votes |
private void deletePasswordDialog(final String password) { if (password.isEmpty()) { Utils.toast(getString(R.string.set_password_first), getActivity()); return; } LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setGravity(Gravity.CENTER); linearLayout.setPadding(30, 20, 30, 20); final AppCompatEditText mPassword = new AppCompatEditText(getActivity()); mPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); mPassword.setHint(getString(R.string.password)); linearLayout.addView(mPassword); new AlertDialog.Builder(getActivity()).setView(linearLayout) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (!mPassword.getText().toString().equals(Utils.decodeString(password))) { Utils.toast(getString(R.string.password_wrong), getActivity()); return; } Utils.saveString("password", "", getActivity()); } }).show(); }
Example 8
Source File: SettingsFragment.java From KernelAdiutor with GNU General Public License v3.0 | 5 votes |
private void deletePasswordDialog(final String password) { if (password.isEmpty()) { Utils.toast(getString(R.string.set_password_first), getActivity()); return; } mDeletePassword = password; LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setGravity(Gravity.CENTER); int padding = Math.round(getResources().getDimension(R.dimen.dialog_padding)); linearLayout.setPadding(padding, padding, padding, padding); final AppCompatEditText mPassword = new AppCompatEditText(getActivity()); mPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); mPassword.setHint(getString(R.string.password)); linearLayout.addView(mPassword); new Dialog(getActivity()).setView(linearLayout) .setPositiveButton(getString(R.string.ok), (dialogInterface, i) -> { if (!mPassword.getText().toString().equals(Utils.decodeString(password))) { Utils.toast(getString(R.string.password_wrong), getActivity()); return; } AppSettings.resetPassword(getActivity()); if (mFingerprint != null) { mFingerprint.setEnabled(false); } }) .setOnDismissListener(dialogInterface -> mDeletePassword = null).show(); }
Example 9
Source File: SettingActivity.java From AccountBook with GNU General Public License v3.0 | 4 votes |
/** * 显示修改密码 Dialog */ private void showUpdatePwdDialog() { final AppCompatEditText editText = new AppCompatEditText(mContext); editText.setHint(UiUtils.getString(R.string.hint_input_new_pwd)); final AlertDialog alertDialog = new AlertDialog.Builder(mContext) .setTitle(UiUtils.getString(R.string.dialog_title_update_pwd)) .setCancelable(false) .setView(editText, DimenUtils.dp2px(16f), DimenUtils.dp2px(16f), DimenUtils.dp2px(16f), DimenUtils.dp2px(16f)) .setNegativeButton(UiUtils.getString(R.string.dialog_cancel), null) .setPositiveButton(UiUtils.getString(R.string.dialog_finish), null) .create(); alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(final DialogInterface dialog) { Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String newPwd = editText.getText().toString(); if(!RegexUtils.checkPassword(newPwd)){ ToastUtils.show(mContext, UiUtils.getString(R.string.toast_right_password)); }else{ User user = UserUtils.getUser(); user.setPassword(newPwd); ProgressUtils.show(mContext, UiUtils.getString(R.string.load_update)); mRepository.saveUserInfo(user, new UserDataSource.SaveUserInfoCallback() { @Override public void saveSuccess() { ProgressUtils.dismiss(); alertDialog.dismiss(); ToastUtils.show(mContext, UiUtils.getString(R.string.toast_update_success)); } @Override public void saveFail(Error e) { ProgressUtils.dismiss(); ToastUtils.show(mContext, e.getMessage()); } }); } } }); } }); alertDialog.show(); }
Example 10
Source File: SettingsFragment.java From KernelAdiutor with GNU General Public License v3.0 | 4 votes |
private void editPasswordDialog(final String oldPass) { mOldPassword = oldPass; LinearLayout linearLayout = new LinearLayout(getActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setGravity(Gravity.CENTER); int padding = Math.round(getResources().getDimension(R.dimen.dialog_padding)); linearLayout.setPadding(padding, padding, padding, padding); final AppCompatEditText oldPassword = new AppCompatEditText(getActivity()); if (!oldPass.isEmpty()) { oldPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); oldPassword.setHint(getString(R.string.old_password)); linearLayout.addView(oldPassword); } final AppCompatEditText newPassword = new AppCompatEditText(getActivity()); newPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); newPassword.setHint(getString(R.string.new_password)); linearLayout.addView(newPassword); final AppCompatEditText confirmNewPassword = new AppCompatEditText(getActivity()); confirmNewPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); confirmNewPassword.setHint(getString(R.string.confirm_new_password)); linearLayout.addView(confirmNewPassword); new Dialog(getActivity()).setView(linearLayout) .setNegativeButton(getString(R.string.cancel), (dialogInterface, i) -> { }) .setPositiveButton(getString(R.string.ok), (dialogInterface, i) -> { if (!oldPass.isEmpty() && !oldPassword.getText().toString().equals(Utils .decodeString(oldPass))) { Utils.toast(getString(R.string.old_password_wrong), getActivity()); return; } if (newPassword.getText().toString().isEmpty()) { Utils.toast(getString(R.string.password_empty), getActivity()); return; } if (!newPassword.getText().toString().equals(confirmNewPassword.getText() .toString())) { Utils.toast(getString(R.string.password_not_match), getActivity()); return; } if (newPassword.getText().toString().length() > 32) { Utils.toast(getString(R.string.password_too_long), getActivity()); return; } AppSettings.savePassword(Utils.encodeString(newPassword.getText() .toString()), getActivity()); if (mFingerprint != null) { mFingerprint.setEnabled(true); } }) .setOnDismissListener(dialogInterface -> mOldPassword = null).show(); }