android.support.design.widget.TextInputLayout Java Examples
The following examples show how to use
android.support.design.widget.TextInputLayout.
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: PlaceSearchDialog.java From place-search-dialog with Apache License 2.0 | 6 votes |
public void init() { locationET = (AppCompatAutoCompleteTextView) findViewById(R.id.place_search_dialog_location_ET); locationTIL = (TextInputLayout) findViewById(R.id.place_search_dialog_location_TIL); cancelTV = (AppCompatTextView) findViewById(R.id.place_search_dialog_cancel_TV); okTV = (AppCompatTextView) findViewById(R.id.place_search_dialog_ok_TV); headerImageIV = (ImageView) findViewById(R.id.place_search_dialog_header_image_IV); okTV.setOnClickListener(this); cancelTV.setOnClickListener(this); buildDialog(); locationET.setOnItemClickListener(mAutocompleteClickListener); mAdapter = new PlaceAutocompleteAdapter(context, mGoogleApiClient, BOUNDS_WORLD, null); locationET.setThreshold(3); locationET.setAdapter(mAdapter); }
Example #2
Source File: ResetPasswordDialog.java From android-login-registration-authentication-client with MIT License | 6 votes |
private void initViews(View v) { mEtEmail = (EditText) v.findViewById(R.id.et_email); mEtToken = (EditText) v.findViewById(R.id.et_token); mEtPassword = (EditText) v.findViewById(R.id.et_password); mBtResetPassword = (Button) v.findViewById(R.id.btn_reset_password); mProgressBar = (ProgressBar) v.findViewById(R.id.progress); mTvMessage = (TextView) v.findViewById(R.id.tv_message); mTiEmail = (TextInputLayout) v.findViewById(R.id.ti_email); mTiToken = (TextInputLayout) v.findViewById(R.id.ti_token); mTiPassword = (TextInputLayout) v.findViewById(R.id.ti_password); mBtResetPassword.setOnClickListener(view -> { if (isInit) resetPasswordInit(); else resetPasswordFinish(); }); }
Example #3
Source File: EventEditView.java From ToDay with MIT License | 6 votes |
public EventEditView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); inflate(context, R.layout.event_edit_view, this); int horizontalPadding = context.getResources() .getDimensionPixelSize(R.dimen.horizontal_padding), verticalPadding = context.getResources() .getDimensionPixelSize(R.dimen.vertical_padding); setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding); mTextInputTitle = (TextInputLayout) findViewById(R.id.text_input_title); mEditTextTitle = (EditText) findViewById(R.id.edit_text_title); mSwitchAllDay = (SwitchCompat) findViewById(R.id.switch_all_day); mTextViewStartDate = (TextView) findViewById(R.id.text_view_start_date); mTextViewStartTime = (TextView) findViewById(R.id.text_view_start_time); mTextViewEndDate = (TextView) findViewById(R.id.text_view_end_date); mTextViewEndTime = (TextView) findViewById(R.id.text_view_end_time); mTextViewCalendar = (TextView) findViewById(R.id.text_view_calendar); mTransparentColor = ContextCompat.getColor(context, android.R.color.transparent); if (isInEditMode()) { mColors = new int[]{mTransparentColor}; } else { mColors = ViewUtils.getCalendarColors(context); } setupViews(); setEvent(mEvent); }
Example #4
Source File: Utils.java From openshop.io-android with MIT License | 6 votes |
/** * Method checks if text input layout exist and contains some value. * If layout is empty, then show error value under the textInputLayout. * * @param textInputLayout textInputFiled for check. * @param errorValue value displayed when ext input is empty. * @return true if everything ok. */ public static boolean checkTextInputLayoutValueRequirement(TextInputLayout textInputLayout, String errorValue) { if (textInputLayout != null && textInputLayout.getEditText() != null) { String text = Utils.getTextFromInputLayout(textInputLayout); if (text == null || text.isEmpty()) { textInputLayout.setErrorEnabled(true); textInputLayout.setError(errorValue); Timber.d("Input field %s missing text.", textInputLayout.getHint()); return false; } else { textInputLayout.setErrorEnabled(false); Timber.d("Input field: %s OK.", textInputLayout.getHint()); return true; } } else { Timber.e(new RuntimeException(), "Checking null input field during order send."); return false; } }
Example #5
Source File: ValidatorTest.java From AwesomeValidation with MIT License | 6 votes |
public void testSetTextInputLayoutWithActivityAndPattern() { Activity mockActivity = mock(Activity.class, RETURNS_DEEP_STUBS); int viewId = 1; Pattern mockPattern = PowerMockito.mock(Pattern.class); int errMsgId = 9; String errMsg = "Error"; TextInputLayout mockTextInputLayout = mock(TextInputLayout.class); when(mockActivity.findViewById(eq(viewId))).thenReturn(mockTextInputLayout); when(mockActivity.getResources().getString(eq(errMsgId))).thenReturn(errMsg); mSpiedValidator.set(mockActivity, viewId, mockPattern, errMsgId); assertEquals(1, mSpiedValidator.mValidationHolderList.size()); ValidationHolder validationHolder = mSpiedValidator.mValidationHolderList.get(0); assertEquals(mockTextInputLayout, validationHolder.getTextInputLayout()); assertEquals(mockPattern, validationHolder.getPattern()); assertEquals(errMsg, validationHolder.getErrMsg()); }
Example #6
Source File: PinTextInputLayout.java From Luhn with MIT License | 6 votes |
private void init() { try { Field cthField = TextInputLayout.class.getDeclaredField("mCollapsingTextHelper"); cthField.setAccessible(true); collapsingTextHelper = cthField.get(this); Field boundsField = collapsingTextHelper.getClass().getDeclaredField("mCollapsedBounds"); boundsField.setAccessible(true); bounds = (Rect) boundsField.get(collapsingTextHelper); recalculateMethod = collapsingTextHelper.getClass().getDeclaredMethod("recalculate"); } catch (NoSuchFieldException | IllegalAccessException | NoSuchMethodException e) { collapsingTextHelper = null; bounds = null; recalculateMethod = null; e.printStackTrace(); } }
Example #7
Source File: ReportBugsHelper.java From candybar-library with Apache License 2.0 | 6 votes |
public static void prepareReportBugs(@NonNull Context context) { MaterialDialog.Builder builder = new MaterialDialog.Builder(context); builder.customView(R.layout.dialog_report_bugs, true); builder.typeface( TypefaceHelper.getMedium(context), TypefaceHelper.getRegular(context)); builder.positiveText(R.string.report_bugs_send); builder.negativeText(R.string.close); MaterialDialog dialog = builder.build(); EditText editText = (EditText) dialog.findViewById(R.id.input_desc); TextInputLayout inputLayout = (TextInputLayout) dialog.findViewById(R.id.input_layout); dialog.getActionButton(DialogAction.POSITIVE).setOnClickListener(view -> { if (editText.getText().length() > 0) { inputLayout.setErrorEnabled(false); ReportBugsTask.start(context, editText.getText().toString(), AsyncTask.THREAD_POOL_EXECUTOR); dialog.dismiss(); return; } inputLayout.setError(context.getResources().getString(R.string.report_bugs_desc_empty)); }); dialog.show(); }
Example #8
Source File: BankTextInputLayout.java From africastalking-android with MIT License | 6 votes |
private void init() { try { Field cthField = TextInputLayout.class.getDeclaredField("mCollapsingTextHelper"); cthField.setAccessible(true); collapsingTextHelper = cthField.get(this); Field boundsField = collapsingTextHelper.getClass().getDeclaredField("mCollapsedBounds"); boundsField.setAccessible(true); bounds = (Rect) boundsField.get(collapsingTextHelper); recalculateMethod = collapsingTextHelper.getClass().getDeclaredMethod("recalculate"); } catch (NoSuchFieldException | IllegalAccessException | NoSuchMethodException e) { collapsingTextHelper = null; bounds = null; recalculateMethod = null; e.printStackTrace(); } }
Example #9
Source File: CommonEditDialog.java From AssistantBySDK with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { Log.i("CommonEditDialog", "onCreate>>limits=" + inputLimits); super.onCreate(savedInstanceState); setContentView(R.layout.common_edit_dialog); findViewById(R.id.ced_confirm).setOnClickListener(this); findViewById(R.id.ced_title).setOnClickListener(this); ((TextView) findViewById(R.id.ced_confirm)).setText(confirm); ((TextView) findViewById(R.id.ced_title)).setText(title); textInputLayout = (TextInputLayout) findViewById(R.id.edit_content); textInputLayout.getEditText().setText(content); textInputLayout.getEditText().setHint(contentHint); int textLength = textInputLayout.getEditText().length(); textInputLayout.getEditText().setSelection(textLength);//设置光标位置 textInputLayout.getEditText().addTextChangedListener(tw); textInputLayout.getEditText().setFilters(new InputFilter[]{new InputFilter.LengthFilter(inputLimits)}); if (oneButtonOnly) { findViewById(R.id.ced_cancel).setVisibility(View.GONE); } else { ((TextView) findViewById(R.id.ced_cancel)).setText(cancel); findViewById(R.id.ced_cancel).setOnClickListener(this); } }
Example #10
Source File: ValorMonetarioWatcherTest.java From canarinho with Apache License 2.0 | 5 votes |
@Before public void setUp() { final ActivityController<Activity> activityController = buildActivity(Activity.class); final Activity activity = activityController.create().get(); activityController.start().resume().visible(); TextInputLayout textInputLayout; activity.setContentView(textInputLayout = new TextInputLayout(activity)); textInputLayout.addView(editText = new EditText(activity)); editText.setText("0,00"); }
Example #11
Source File: PopupSetting.java From AnimatedPieView with Apache License 2.0 | 5 votes |
private int getTextInt(TextInputLayout v, int defaultValue) { try { int value = Integer.parseInt(v.getEditText().getText().toString().trim()); return value; } catch (Exception e) { return defaultValue; } }
Example #12
Source File: AddDataStreamActivity.java From AndroidSDK with MIT License | 5 votes |
private boolean checkInput(TextInputLayout textInputLayout, int errorResId) { String text = textInputLayout.getEditText().getText().toString(); if (TextUtils.isEmpty(text)) { textInputLayout.setError(getResources().getString(errorResId)); textInputLayout.requestFocus(); return false; } return true; }
Example #13
Source File: OIDCClientConfigurationActivity.java From android-java-connect-rest-sample with MIT License | 5 votes |
@SuppressWarnings("ConstantConditions") private void setupClientConfigurationForm() { useOAuthSwitch = (SwitchCompat) findViewById(R.id.useOauth2Switch); validateClientButton = (Button) findViewById(R.id.setOIDCClientButton); validateClientButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveClientConfigurationForm(v); } }); flowTypeSpinner = (Spinner) findViewById(R.id.flowTypeSpinner); FlowTypesAdapter adapter = new FlowTypesAdapter(this, R.layout.spinner_selected_item, OIDCRequestManager.Flows.values()); flowTypeSpinner.setAdapter(adapter); clientIdInputLayout = (TextInputLayout) findViewById(R.id.clientIdInputLayout); clientIdInputLayout.getEditText().addTextChangedListener(new OIDCOptionsTextWatcher(clientIdInputLayout)); clientIdEdit = (EditText) findViewById(R.id.clientIdEditText); clientSecretInputLayout = (TextInputLayout) findViewById(R.id.clientSecretInputLayout); clientSecretInputLayout.getEditText().addTextChangedListener(new OIDCOptionsTextWatcher(clientSecretInputLayout)); clientSecretEdit = (EditText) findViewById(R.id.clientSecretEditText); redirectUriInputLayout = (TextInputLayout) findViewById(R.id.redirectUriInputLayout); redirectUriInputLayout.getEditText().addTextChangedListener(new OIDCOptionsTextWatcher(redirectUriInputLayout)); redirectUriEdit = (EditText) findViewById(R.id.redirectUriEditText); issuerInputLayout = (TextInputLayout) findViewById(R.id.issuerInputLayout); issuerInputLayout.getEditText().addTextChangedListener(new OIDCOptionsTextWatcher(issuerInputLayout)); issuerEdit = (EditText) findViewById(R.id.issuerEditText); scopesInputLayout = (TextInputLayout) findViewById(R.id.scopesInputLayout); scopesInputLayout.getEditText().addTextChangedListener(new OIDCOptionsTextWatcher(scopesInputLayout)); scopesEdit = (EditText) findViewById(R.id.scopesEditText); }
Example #14
Source File: InputLayoutErrorMatcher.java From AndroidSchool with Apache License 2.0 | 5 votes |
@Override protected boolean matchesSafely(View item) { if (!(item instanceof TextInputLayout)) { return false; } String expectedError = item.getResources().getString(mErrorTextId); TextInputLayout layout = (TextInputLayout) item; return TextUtils.equals(expectedError, layout.getError()); }
Example #15
Source File: ValidationUtils.java From q-municate-android with Apache License 2.0 | 5 votes |
public boolean isChangePasswordDataValid(TextInputLayout oldPasswordTextInputLayout, TextInputLayout newPasswordTextInputLayout, String oldPassword, String newPassword) { boolean isOldPasswordEntered = !TextUtils.isEmpty(oldPassword.trim()); boolean isNewPasswordEntered = !TextUtils.isEmpty(newPassword.trim()); if (isOldPasswordEntered && isNewPasswordEntered) { if (!qbUser.getPassword().equals(oldPassword)) { oldPasswordTextInputLayout.setError(context.getString(R.string.change_password_old_password_wrong)); } else { return true; } } else if (!isOldPasswordEntered && !isNewPasswordEntered) { oldPasswordTextInputLayout.setError(context.getString(R.string.change_password_all_fields_not_entered)); newPasswordTextInputLayout.setError(context.getString(R.string.change_password_all_fields_not_entered)); } else { if (!isOldPasswordEntered) { oldPasswordTextInputLayout .setError(context.getString(R.string.change_password_old_password_not_entered)); } if (!isNewPasswordEntered) { newPasswordTextInputLayout .setError(context.getString(R.string.change_password_new_password_not_entered)); } } return false; }
Example #16
Source File: AddDeviceActivity.java From AndroidSDK with MIT License | 5 votes |
private boolean checkInput(TextInputLayout textInputLayout, int errorResId) { String text = textInputLayout.getEditText().getText().toString(); if (TextUtils.isEmpty(text)) { textInputLayout.setError(getResources().getString(errorResId)); textInputLayout.requestFocus(); return false; } return true; }
Example #17
Source File: MRLPanelFragment.java From VCL-Android with Apache License 2.0 | 5 votes |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){ ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.open_mrl_dialog_title); View v = inflater.inflate(R.layout.mrl_panel, container, false); mRootView = v.findViewById(R.id.mrl_root); mEditText = (TextInputLayout) v.findViewById(R.id.mrl_edit); mEditText.getEditText().setOnKeyListener(this); mEditText.getEditText().setOnEditorActionListener(this); mEditText.setHint(getString(R.string.open_mrl_dialog_msg)); mRecyclerView = (RecyclerView) v.findViewById(R.id.mrl_list); mLayoutManager = new LinearLayoutManager(getActivity()); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new MRLAdapter(mHistory); mRecyclerView.setAdapter(mAdapter); return v; }
Example #18
Source File: TextInputLayoutValidator.java From AwesomeValidation with MIT License | 5 votes |
@Override public void execute(ValidationHolder validationHolder, Matcher matcher) { TextInputLayout textInputLayout = validationHolder.getTextInputLayout(); textInputLayout.setErrorTextAppearance(mErrorTextAppearance); textInputLayout.setErrorEnabled(true); textInputLayout.setError(validationHolder.getErrMsg()); }
Example #19
Source File: SkinMaterialTextInputLayout.java From Android-skin-support with MIT License | 5 votes |
private TextView getCounterView() { try { Field counterView = TextInputLayout.class.getDeclaredField("mCounterView"); counterView.setAccessible(true); return (TextView) counterView.get(this); } catch (Exception e) { e.printStackTrace(); } return null; }
Example #20
Source File: Validator.java From AwesomeValidation with MIT License | 5 votes |
public void set(Activity activity, int viewId, SimpleCustomValidation simpleCustomValidation, int errMsgId) { View view = activity.findViewById(viewId); String errMsg = activity.getResources().getString(errMsgId); if (view instanceof EditText) { set((EditText) view, simpleCustomValidation, errMsg); } else if (view instanceof TextInputLayout) { set((TextInputLayout) view, simpleCustomValidation, errMsg); } }
Example #21
Source File: SkinMaterialTextInputLayout.java From Android-skin-support with MIT License | 5 votes |
private void updateEditTextBackgroundInternal() { try { Method updateEditTextBackground = TextInputLayout.class.getDeclaredMethod("updateEditTextBackground"); updateEditTextBackground.setAccessible(true); updateEditTextBackground.invoke(this); } catch (Exception e) { e.printStackTrace(); } }
Example #22
Source File: Validator.java From AwesomeValidation with MIT License | 5 votes |
public void set(Activity activity, int viewId, NumericRange numericRange, int errMsgId) { View view = activity.findViewById(viewId); String errMsg = activity.getResources().getString(errMsgId); if (view instanceof EditText) { set((EditText) view, numericRange, errMsg); } else if (view instanceof TextInputLayout) { set((TextInputLayout) view, numericRange, errMsg); } }
Example #23
Source File: SkinMaterialTextInputLayout.java From Android-skin-support with MIT License | 5 votes |
private void setFocusedTextColor(ColorStateList colors) { try { Field focusedTextColor = TextInputLayout.class.getDeclaredField("mFocusedTextColor"); focusedTextColor.setAccessible(true); focusedTextColor.set(this, colors); updateLabelState(); } catch (Exception e) { e.printStackTrace(); } }
Example #24
Source File: SignUpFragment.java From android-login with MIT License | 5 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (view != null) { view.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.color_sign_up)); caption.setText(getString(R.string.sign_up_label)); for (TextInputEditText editText : views) { if (editText.getId() == R.id.password_input_edit) { final TextInputLayout inputLayout = ButterKnife.findById(view, R.id.password_input); final TextInputLayout confirmLayout = ButterKnife.findById(view, R.id.confirm_password); Typeface boldTypeface = Typeface.defaultFromStyle(Typeface.BOLD); inputLayout.setTypeface(boldTypeface); confirmLayout.setTypeface(boldTypeface); editText.addTextChangedListener(new TextWatcherAdapter() { @Override public void afterTextChanged(Editable editable) { inputLayout.setPasswordVisibilityToggleEnabled(editable.length() > 0); } }); } editText.setOnFocusChangeListener((temp, hasFocus) -> { if (!hasFocus) { boolean isEnabled = editText.getText().length() > 0; editText.setSelected(isEnabled); } }); } caption.setVerticalText(true); foldStuff(); caption.setTranslationX(getTextPadding()); } }
Example #25
Source File: TextInputAutoCompleteTextView.java From TextFieldBoxes with Apache License 2.0 | 5 votes |
@Override public InputConnection onCreateInputConnection(EditorInfo outAttrs) { final InputConnection ic = super.onCreateInputConnection(outAttrs); if (ic != null && outAttrs.hintText == null) { // If we don't have a hint and our parent is a TextInputLayout, use it's hint for the // EditorInfo. This allows us to display a hint in 'extract mode'. final ViewParent parent = getParent(); if (parent instanceof TextInputLayout) { outAttrs.hintText = ((TextInputLayout) parent).getHint(); } } return ic; }
Example #26
Source File: FolderManagerFragment.java From MarkdownEditors with Apache License 2.0 | 5 votes |
/** * 新建文件夹 * Create folder. */ public void createFolder() { //显示重命名对话框 View rootView = LayoutInflater.from(mContext).inflate(R.layout.view_common_input_view, null); AlertDialog mInputDialog = new AlertDialog.Builder(mContext) .setTitle("新建文件夹") .setView(rootView) .show(); TextInputLayout textInputLayout = (TextInputLayout) rootView.findViewById(R.id.inputHint); EditText text = (EditText) rootView.findViewById(R.id.text); textInputLayout.setHint("请输入文件夹名"); rootView.findViewById(R.id.sure).setOnClickListener(v -> { String result = text.getText().toString().trim(); if (Check.isEmpty(result)) { textInputLayout.setError("不能为空"); return; } if (mPresenter.createFoloderIsExists(result)) { textInputLayout.setError("文件已经存在"); return; } mPresenter.createFolder(result); mInputDialog.dismiss(); }); rootView.findViewById(R.id.cancel).setOnClickListener(v -> { mInputDialog.dismiss(); }); mInputDialog.show(); }
Example #27
Source File: TextFragment.java From BrainPhaser with GNU General Public License v3.0 | 5 votes |
/** * Setups the view * * @param inflater Inflates the fragment * @param container Container to inflate the fragment * @param savedInstanceState Ignored * @return Return the inflated view */ @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_challenge_text, container, false); mAnswerInput = (EditText) view.findViewById(R.id.answerText); mAnswerInputLayout = (TextInputLayout) view.findViewById(R.id.input_answer_layout); mAnswerInput.setOnEditorActionListener(this); return view; }
Example #28
Source File: InsertHelper.java From ForPDA with GNU General Public License v3.0 | 5 votes |
public void setBody(String title, String value) { if (true) { this.body = new Pair<>(title, value); TextInputLayout inputLayout = (TextInputLayout) inflater.inflate(R.layout.insert_helper_item, null); inputLayout.setHint(title); TextView textView = (TextView) inputLayout.findViewById(R.id.insert_helper_item_text); textView.setText(value); bodyLayout = inputLayout.getEditText(); itemsContainer.addView(inputLayout); } }
Example #29
Source File: TextInputLayoutValidator.java From AwesomeValidation with MIT License | 5 votes |
@Override public void halt() { for (ValidationHolder validationHolder : mValidationHolderList) { if (validationHolder.isSomeSortOfView()) { validationHolder.resetCustomError(); } else { TextInputLayout textInputLayout = validationHolder.getTextInputLayout(); textInputLayout.setErrorEnabled(false); textInputLayout.setError(null); } } }
Example #30
Source File: EnrollActivity.java From Android-Bluetooth-Fingerprint with Apache License 2.0 | 5 votes |
private boolean validateInput(EditText EdTxt, TextInputLayout inputLayout) { if (EdTxt.getText().toString().trim().isEmpty()) { inputLayout.setError(getString(R.string.err_msg_input)); requestFocus(EdTxt); return false; } else { inputLayout.setErrorEnabled(false); } return true; }