Java Code Examples for android.widget.TextView#setInputType()

The following examples show how to use android.widget.TextView#setInputType() . These examples are extracted from open source projects. 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 Project: AndroidFrame   File: GridPasswordView.java    License: Apache License 2.0 6 votes vote down vote up
private void setCustomAttr(TextView view) {
    if (mTextColor != null)
        view.setTextColor(mTextColor);
    view.setTextSize(mTextSize);

    int inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD;
    switch (mPasswordType) {

        case 1:
            inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
            break;

        case 2:
            inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
            break;

        case 3:
            inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD;
            break;
    }
    view.setInputType(inputType);
    view.setTransformationMethod(mTransformationMethod);
}
 
Example 2
Source Project: AndroidFrame   File: GridPasswordView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void setPasswordType(PasswordType passwordType) {
    boolean visible = getPassWordVisibility();
    int inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD;
    switch (passwordType) {

        case TEXT:
            inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
            break;

        case TEXTVISIBLE:
            inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
            break;

        case TEXTWEB:
            inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD;
            break;
    }

    for (TextView textView : mViewArr)
        textView.setInputType(inputType);

    setPasswordVisibility(visible);
}
 
Example 3
private TextView setupDetailsView(final int inputType, final String hint) {
    setView(R.layout.activity_two_factor_3_provide_details, R.id.activity_two_factor_3_provide_details);

    final TextView detailsText = UI.find(this, R.id.details);
    detailsText.setInputType(inputType);
    detailsText.setHint(hint);

    final InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
    // Show the keyboard; this workaround is needed due to Android bugs
    detailsText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                detailsText.postDelayed(() -> {
                    detailsText.requestFocus();
                    imm.showSoftInput(detailsText, 0);
                }, 100);
            }
        }
    });
    return detailsText;
}
 
Example 4
private void setUpTable(final int id, final int startWordNum) {
    int wordNum = startWordNum;
    final TableLayout table = UI.find(this, id);

    for (int y = 0; y < table.getChildCount(); ++y) {
        final TableRow row = (TableRow) table.getChildAt(y);

        for (int x = 0; x < row.getChildCount() / 2; ++x) {
            ((TextView) row.getChildAt(x * 2)).setText(String.valueOf(wordNum));

            TextView me = (TextView) row.getChildAt(x * 2 + 1);
            me.setInputType(0);
            me.addTextChangedListener(new UI.TextWatcher() {
                @Override
                public void afterTextChanged(final Editable s) {
                    super.afterTextChanged(s);
                    final String original = s.toString();
                    final String trimmed = original.trim();
                    if (!trimmed.isEmpty() && !trimmed.equals(original)) {
                        me.setText(trimmed);
                    }
                }
            });
            registerForContextMenu(me);

            mTextViews[wordNum - 1] = me;
            ++wordNum;
        }
    }
}
 
Example 5
Source Project: CallMeMaybe   File: CallMeMaybe.java    License: Apache License 2.0 5 votes vote down vote up
public static void attachTo(final TextView textView, final FormatParameters parameters) {
  ensurePhoneNumberUtil(textView.getContext());
  textView.setInputType(EditorInfo.TYPE_CLASS_PHONE);
  textView.setEditableFactory(new Editable.Factory() {
    @Override
    public Editable newEditable(final CharSequence source) {
      return new PhoneStringBuilder(phoneNumberUtil, source, parameters);
    }
  });
}
 
Example 6
Source Project: Android-Shortify   File: Views.java    License: Apache License 2.0 5 votes vote down vote up
public static $ capitalize(){
    try{
        if(mView instanceof TextView){
            TextView textView = (TextView) mView;
            textView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
        }
    }catch (Exception e){
        Log.d(TAG, e.getMessage());
    }
    return  $.getInstance();
}
 
Example 7
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    final Context context = getContext();

    textView = (TextView) getChildAt(0);
    textView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    textView.setHintTextColor(lessSignificantColor);
    textView.setHorizontalFadingEdgeEnabled(true);
    textView.setSingleLine();
    textView.setCompoundDrawablePadding(UIUtil.dip2pix(2));
    setHint(0);
    setValidateAmount(textView instanceof EditText);
    textView.addTextChangedListener(textViewListener);
    textView.setOnFocusChangeListener(textViewListener);
    textView.setOnEditorActionListener(textViewListener);

    contextButton = new View(context) {
        @Override
        protected void onMeasure(final int wMeasureSpec, final int hMeasureSpec) {
            setMeasuredDimension(textView.getCompoundPaddingRight(),
                    textView.getMeasuredHeight());
        }
    };
    final LayoutParams chooseViewParams = new LayoutParams(ViewGroup.LayoutParams
            .WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    chooseViewParams.gravity = Gravity.RIGHT;
    contextButton.setLayoutParams(chooseViewParams);
    this.addView(contextButton);

    updateAppearance();
}
 
Example 8
private void startEditTagsMode() {
    ImageButton editButton = getActivity().findViewById(R.id.edit_tags_btn);
    editButton.setImageResource(R.drawable.ic_edit_anim);
    ((Animatable) editButton.getDrawable()).start();

    ((DrawerLayout) ((MainActivity) getActivity()).drawer).setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    mRefreshLayout.setEnabled(false);
    getActivity().findViewById(R.id.refresh_fab).setEnabled(false);
    ((RefreshIcon) getActivity().findViewById(R.id.refresh_fab)).hide();
    ((Toolbar) getActivity().findViewById(R.id.toolbar)).getMenu().clear();

    ViewSwitcher viewSwitcher = getActivity().findViewById(R.id.switcher);
    EditText songTV = getActivity().findViewById(R.id.song);
    TextView artistTV = getActivity().findViewById(R.id.artist);

    EditText newLyrics = getActivity().findViewById(R.id.edit_lyrics);
    newLyrics.setTypeface(LyricsTextFactory.FontCache.get("light", getActivity()));
    newLyrics.setText(Html.fromHtml(TextUtils.isEmpty(mLyrics.getText()) ? "" : mLyrics.getText()), TextView.BufferType.EDITABLE);

    viewSwitcher.setVisibility(View.GONE);
    newLyrics.setVisibility(View.VISIBLE);

    songTV.setInputType(InputType.TYPE_CLASS_TEXT);
    artistTV.setInputType(InputType.TYPE_CLASS_TEXT);
    songTV.setBackgroundResource(R.drawable.abc_textfield_search_material);
    artistTV.setBackgroundResource(R.drawable.abc_textfield_search_material);


    if (songTV.requestFocus()) {
        InputMethodManager imm = (InputMethodManager)
                getActivity().getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.SHOW_IMPLICIT);
    }
}
 
Example 9
private void initView(){



        View view = mInflater.inflate(R.layout.widet_num_add_sub,this,true);

        mEtxtNum = (TextView) view.findViewById(R.id.etxt_num);
        mEtxtNum.setInputType(InputType.TYPE_NULL);
        mEtxtNum.setKeyListener(null);



        mBtnAdd = (Button) view.findViewById(R.id.btn_add);
        mBtnSub = (Button) view.findViewById(R.id.btn_sub);

        mBtnAdd.setOnClickListener(this);
        mBtnSub.setOnClickListener(this);



    }
 
Example 10
Source Project: enjoyshop   File: NumberAddSubView.java    License: Apache License 2.0 4 votes vote down vote up
private void initView() {


        View view = mInflater.inflate(R.layout.widet_num_add_sub, this, true);

        mEtxtNum = (TextView) view.findViewById(R.id.etxt_num);
        mEtxtNum.setInputType(InputType.TYPE_NULL);
        mEtxtNum.setKeyListener(null);


        mBtnAdd = (Button) view.findViewById(R.id.btn_add);
        mBtnSub = (Button) view.findViewById(R.id.btn_sub);

        mBtnAdd.setOnClickListener(this);
        mBtnSub.setOnClickListener(this);

    }