android.widget.TextView.setInputType()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(163)

本文整理了Java中android.widget.TextView.setInputType()方法的一些代码示例,展示了TextView.setInputType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setInputType()方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setInputType

TextView.setInputType介绍

暂无

代码示例

代码示例来源:origin: robolectric/robolectric

@Test
public void testGetInputType() throws Exception {
 assertThat(textView.getInputType()).isNotEqualTo(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
 textView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
 assertThat(textView.getInputType()).isEqualTo(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
}

代码示例来源:origin: Jungerr/GridPasswordView

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);
}

代码示例来源:origin: Jungerr/GridPasswordView

@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);
}

代码示例来源:origin: stackoverflow.com

EditTextPreference editTextPreference = (EditTextPreference) preference;
   TextView etpTextView = (TextView) editTextPreference.getEditText();
   // If I want entry with decimal capability
   etpTextView.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
   // or if I want entry without decimal capability
   etpTextView.setInputType(InputType.TYPE_CLASS_NUMBER);

代码示例来源:origin: stackoverflow.com

TextView txtCapitalize = (TextView) findViewById(R.id.txtCapitalize);
txtCapitalize.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS);

代码示例来源:origin: nickwah/DynamicLayoutInflator

@Override
  public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
    if (view instanceof TextView) {
      int inputType = 0;
      switch (value) {
        case "textEmailAddress":
          inputType |= InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
          break;
        case "number":
          inputType |= InputType.TYPE_CLASS_NUMBER;
          break;
        case "phone":
          inputType |= InputType.TYPE_CLASS_PHONE;
          break;
      }
      if (inputType > 0) ((TextView)view).setInputType(inputType);
    }
  }
});

代码示例来源:origin: stackoverflow.com

protected void setGooglePlusButtonText(SignInButton signInButton, String buttonText) {
   for (int i = 0; i < signInButton.getChildCount(); i++) {
     View v = signInButton.getChildAt(i);
     if (v instanceof TextView) {
       TextView tv = (TextView) v;
       tv.setTextSize(15);
       tv.setTypeface(null, Typeface.NORMAL);
       tv.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
       tv.setText(buttonText);
       return;
     }
   }
 }

代码示例来源:origin: stackoverflow.com

TextView tvContent = new TextView(getActivity());
 medicineName.add(tvContent);
 LinearLayout.LayoutParams tvParam = new LinearLayout.LayoutParams(
     ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
 tvContent.setLayoutParams(tvParam);
 tvContent.setGravity(Gravity.LEFT);
 tvContent.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
 tvContent.setText(name);
 tvContent.setTextSize(16);
 layout.addView(tvContent);

代码示例来源:origin: gaolhjy/enjoyshop

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);
}

代码示例来源:origin: JmStefanAndroid/PVCloudGroupn

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);
}

代码示例来源:origin: Tencent/RapidView

public void run(RapidParserObject object, Object view, Var value) {
    ((TextView)view).setInputType(value.getInt());
  }
}

代码示例来源:origin: stackoverflow.com

textview_countries.setInputType(InputType.TYPE_NULL); //To hide the softkeyboard

代码示例来源:origin: stackoverflow.com

LinearLayout layout = new LinearLayout(getActivity());
  LinearLayout.LayoutParams lLayoutlayoutParams = new LinearLayout.LayoutParams(
      ViewGroup.LayoutParams.MATCH_PARENT,
      ViewGroup.LayoutParams.WRAP_CONTENT);
  lLayoutlayoutParams.setMargins(0, 8, 8, 8);
  layout.setLayoutParams(lLayoutlayoutParams);
  layout.setPadding((int) (fDimRatio * 8), (int) (fDimRatio * 8),
      (int) (fDimRatio * 8), (int) (fDimRatio * 8));
  layout.setOrientation(LinearLayout.VERTICAL);


TextView tvContent = new TextView(getActivity());
  medicineName.add(tvContent);
  LinearLayout.LayoutParams tvParam = new LinearLayout.LayoutParams(
      ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
  tvContent.setLayoutParams(tvParam);
  tvContent.setGravity(Gravity.LEFT);
  tvContent.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
  tvContent.setText(name);
  tvContent.setTextSize(16);
  layout.addView(tvContent);

linearLayout.addView(layout);

代码示例来源:origin: MichaelRocks/CallMeMaybe

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);
  }
 });
}

代码示例来源:origin: stackoverflow.com

btnClick = (Button)findViewById(R.id.btnClick);
txtValue.setInputType(InputType.TYPE_NULL);
btnClick.setOnClickListener(new OnClickListener() {
  public void onClick(View arg0) {
    if(txtValue.getInputType()==InputType.TYPE_NULL){
      txtValue.setInputType(InputType.TYPE_CLASS_TEXT);
      txtValue.invalidate();
      btnClick.setText("Disable Input");
    }else{
      txtValue.setInputType(InputType.TYPE_NULL);
      txtValue.invalidate();
      btnClick.setText("Enable Input");

代码示例来源:origin: limboemu/limbo

public static void UIAlertLog(final Activity activity, String title, Spannable body) {
  AlertDialog alertDialog;
  alertDialog = new AlertDialog.Builder(activity).create();
  alertDialog.setTitle(title);
  TextView textView = new TextView(activity);
  textView.setPadding(20,20,20,20);
  textView.setText(body);
  textView.setBackgroundColor(Color.BLACK);
  textView.setTextSize(12);
  textView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
  textView.setSingleLine(false);
  ScrollView view = new ScrollView(activity);
  view.addView(textView);
  alertDialog.setView(view);
  alertDialog.setCanceledOnTouchOutside(false);
  alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
      return;
    }
  });
  alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL, "Copy To", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
      UIUtils.toastShort(activity, "Choose a Directory to save the logfile");
      FileManager.browse(activity, LimboActivity.FileType.LOG_DIR, Config.OPEN_LOG_FILE_DIR_REQUEST_CODE);
      return;
    }
  });
  alertDialog.show();
}

代码示例来源:origin: jelic98/dynamico

textView.setInputType(InputType.TYPE_CLASS_TEXT);
}else if(type.equalsIgnoreCase("class_datetime")) {
  textView.setInputType(InputType.TYPE_CLASS_DATETIME);
}else if(type.equalsIgnoreCase("class_number")) {
  textView.setInputType(InputType.TYPE_CLASS_NUMBER);
}else if(type.equalsIgnoreCase("class_phone")) {
  textView.setInputType(InputType.TYPE_CLASS_PHONE);
}else if(type.equalsIgnoreCase("datetime_variation_date")) {
  textView.setInputType(InputType.TYPE_DATETIME_VARIATION_DATE);
}else if(type.equalsIgnoreCase("datetime_variation_normal")) {
  textView.setInputType(InputType.TYPE_DATETIME_VARIATION_NORMAL);
}else if(type.equalsIgnoreCase("datetime_variation_time")) {
  textView.setInputType(InputType.TYPE_DATETIME_VARIATION_TIME);
}else if(type.equalsIgnoreCase("mask_class")) {
  textView.setInputType(InputType.TYPE_MASK_CLASS);
}else if(type.equalsIgnoreCase("mask_flags")) {
  textView.setInputType(InputType.TYPE_MASK_FLAGS);
}else if(type.equalsIgnoreCase("mask_variation")) {
  textView.setInputType(InputType.TYPE_MASK_VARIATION);
}else if(type.equalsIgnoreCase("null")) {
  textView.setInputType(InputType.TYPE_NULL);
}else if(type.equalsIgnoreCase("number_flag_decimal")) {
  textView.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
}else if(type.equalsIgnoreCase("number_flag_signed")) {
  textView.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED);
}else if(type.equalsIgnoreCase("number_variation_normal")) {
  textView.setInputType(InputType.TYPE_NUMBER_VARIATION_NORMAL);
}else if(type.equalsIgnoreCase("number_variation_password")) {
  textView.setInputType(InputType.TYPE_NUMBER_VARIATION_PASSWORD);

代码示例来源:origin: THEONE10211024/ApiDemos

c.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD);
p.addView(c, new LayoutParams(passwordRow, fieldColumn));

代码示例来源:origin: qiubiteme/android_api_demos

c.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD);
p.addView(c, new LayoutParams(passwordRow, fieldColumn));

相关文章

微信公众号

最新文章

更多

TextView类方法