Java Code Examples for com.google.android.material.textfield.TextInputLayout#setHint()
The following examples show how to use
com.google.android.material.textfield.TextInputLayout#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: TextInputLayoutActions.java From material-components-android with Apache License 2.0 | 6 votes |
public static ViewAction setHint(final String hint) { return new ViewAction() { @Override public Matcher<View> getConstraints() { return isAssignableFrom(TextInputLayout.class); } @Override public String getDescription() { return "Sets the hint/label text"; } @Override public void perform(UiController uiController, View view) { TextInputLayout layout = (TextInputLayout) view; layout.setHint(hint); } }; }
Example 2
Source File: EditTextDialogBuilder.java From MHViewer with Apache License 2.0 | 5 votes |
@SuppressLint("InflateParams") public EditTextDialogBuilder(Context context, String text, String hint) { super(context); View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_edittext_builder, null); setView(view); mTextInputLayout = (TextInputLayout) view; mEditText = (EditText) view.findViewById(R.id.edit_text); mEditText.setText(text); mEditText.setSelection(mEditText.getText().length()); mEditText.setOnEditorActionListener(this); mTextInputLayout.setHint(hint); }
Example 3
Source File: PasswordResetFragment.java From tindroid with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(@NonNull View view, Bundle savedInstance) { Bundle args = getArguments(); String method = args != null ? args.getString(ARG_KEY) : "email"; TextView text = view.findViewById(R.id.callToReset); text.setText(getString(R.string.request_pass_reset, method)); TextInputLayout hint = view.findViewById(R.id.responseHint); hint.setHint(getString(R.string.validated_address_to_use, method)); }
Example 4
Source File: EditTextDialogBuilder.java From EhViewer with Apache License 2.0 | 5 votes |
@SuppressLint("InflateParams") public EditTextDialogBuilder(Context context, String text, String hint) { super(context); View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_edittext_builder, null); setView(view); mTextInputLayout = (TextInputLayout) view; mEditText = (EditText) view.findViewById(R.id.edit_text); mEditText.setText(text); mEditText.setSelection(mEditText.getText().length()); mEditText.setOnEditorActionListener(this); mTextInputLayout.setHint(hint); }
Example 5
Source File: BookmarkDialog.java From HaoReader with GNU General Public License v3.0 | 4 votes |
@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { tvContent = findViewById(R.id.tie_content); TextInputLayout tilReplaceTo = findViewById(R.id.til_content); tilReplaceTo.setHint(getResources().getString(R.string.content)); TextView tvChapterName = findViewById(R.id.tvChapterName); tvChapterName.setOnClickListener(v -> { if(bookmarkClick != null) { bookmarkClick.openBookmark(bookmarkBean); } dismissAllowingStateLoss(); }); View tvOk = findViewById(R.id.tv_ok); tvOk.setOnClickListener(v -> { dismissAllowingStateLoss(); bookmarkBean.setContent(StringUtils.valueOf(tvContent.getText())); if(bookmarkClick != null) { bookmarkClick.saveBookmark(bookmarkBean); } }); View tvSave = findViewById(R.id.tv_save); tvSave.setOnClickListener(v -> { dismissAllowingStateLoss(); bookmarkBean.setContent(StringUtils.valueOf(tvContent.getText())); if(bookmarkClick != null) { bookmarkClick.saveBookmark(bookmarkBean); } }); View tvDel = findViewById(R.id.tv_del); tvDel.setOnClickListener(v -> { dismissAllowingStateLoss(); if(bookmarkClick != null) { bookmarkClick.delBookmark(bookmarkBean); } }); View llEdit = findViewById(R.id.llEdit); if (isAdd) { llEdit.setVisibility(View.GONE); tvOk.setVisibility(View.VISIBLE); tvChapterName.setEnabled(false); } else { llEdit.setVisibility(View.VISIBLE); tvOk.setVisibility(View.GONE); tvChapterName.setEnabled(true); } tvChapterName.setText(bookmarkBean.getChapterName()); tvContent.setText(bookmarkBean.getContent()); }
Example 6
Source File: AuthenticateActivity.java From andOTP with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.auth_activity_title); if (! settings.getScreenshotsEnabled()) getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE); setContentView(R.layout.activity_container); Toolbar toolbar = findViewById(R.id.container_toolbar); toolbar.setNavigationIcon(null); setSupportActionBar(toolbar); ViewStub stub = findViewById(R.id.container_stub); stub.setLayoutResource(R.layout.content_authenticate); View v = stub.inflate(); Intent callingIntent = getIntent(); int labelMsg = callingIntent.getIntExtra(Constants.EXTRA_AUTH_MESSAGE, R.string.auth_msg_authenticate); newEncryption = callingIntent.getStringExtra(Constants.EXTRA_AUTH_NEW_ENCRYPTION); TextView passwordLabel = v.findViewById(R.id.passwordLabel); TextInputLayout passwordLayout = v.findViewById(R.id.passwordLayout); passwordInput = v.findViewById(R.id.passwordEdit); if (settings.getBlockAccessibility()) passwordLayout.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && settings.getBlockAutofill()) passwordLayout.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS); passwordLabel.setText(labelMsg); authMethod = settings.getAuthMethod(); password = settings.getAuthCredentials(); if (password.isEmpty()) { password = settings.getOldCredentials(authMethod); oldPassword = true; } if (authMethod == AuthMethod.PASSWORD) { if (password.isEmpty()) { Toast.makeText(this, R.string.auth_toast_password_missing, Toast.LENGTH_LONG).show(); finishWithResult(true, null); } else { passwordLayout.setHint(getString(R.string.auth_hint_password)); passwordInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } } else if (authMethod == AuthMethod.PIN) { if (password.isEmpty()) { Toast.makeText(this, R.string.auth_toast_pin_missing, Toast.LENGTH_LONG).show(); finishWithResult(true, null); } else { passwordLayout.setHint(getString(R.string.auth_hint_pin)); passwordInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); } } else { finishWithResult(true, null); } passwordInput.setTransformationMethod(new PasswordTransformationMethod()); passwordInput.setOnEditorActionListener(this); Button unlockButton = v.findViewById(R.id.buttonUnlock); unlockButton.setOnClickListener(this); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); }
Example 7
Source File: PasswordEncryptedPreference.java From andOTP with MIT License | 4 votes |
@Override protected void onBindDialogView(View view) { Settings settings = new Settings(getContext()); TextInputLayout passwordLayout = view.findViewById(R.id.passwordLayout); passwordInput = view.findViewById(R.id.passwordEdit); passwordConfirm = view.findViewById(R.id.passwordConfirm); if (settings.getBlockAccessibility()) { passwordLayout.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); passwordConfirm.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && settings.getBlockAutofill()) { passwordLayout.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS); passwordConfirm.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO); } Button btnCancel = view.findViewById(R.id.btnCancel); btnSave = view.findViewById(R.id.btnSave); btnSave.setEnabled(false); btnCancel.setOnClickListener(this); btnSave.setOnClickListener(this); if (! value.isEmpty()) { passwordInput.setText(value); } if (mode == Mode.PASSWORD) { passwordLayout.setHint(getContext().getString(R.string.settings_hint_password)); passwordConfirm.setHint(R.string.settings_hint_password_confirm); passwordInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); passwordConfirm.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } else if (mode == Mode.PIN) { passwordLayout.setHint(getContext().getString(R.string.settings_hint_pin)); passwordConfirm.setHint(R.string.settings_hint_pin_confirm); passwordInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); passwordConfirm.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD); } passwordInput.setTransformationMethod(new PasswordTransformationMethod()); passwordConfirm.setTransformationMethod(new PasswordTransformationMethod()); passwordConfirm.addTextChangedListener(this); passwordInput.addTextChangedListener(this); super.onBindDialogView(view); }
Example 8
Source File: TextFieldControllableDemoFragment.java From material-components-android with Apache License 2.0 | 4 votes |
private void setAllTextFieldsLabel(String label) { for (TextInputLayout textfield : textfields) { textfield.setHint(label); } }