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

x33g5p2x  于2022-01-18 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(209)

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

EditText.setInputType介绍

暂无

代码示例

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

EditText editor = new EditText(this); 
editor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);

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

EditText edtView=(EditText)findViewById(R.id.editTextConvertValue);
edtView.setInputType(0);

代码示例来源:origin: RobotiumTech/robotium

public void run()
  {
    editText.setInputType(InputType.TYPE_NULL);
  }
});

代码示例来源:origin: rey5137/material

/**
 * Set the type of the content with a constant as defined for {@link EditorInfo#inputType}. This
 * will take care of changing the key listener, by calling {@link #setKeyListener(KeyListener)},
 * to match the given content type.  If the given content type is {@link EditorInfo#TYPE_NULL}
 * then a soft keyboard will not be displayed for this text view.
 *
 * Note that the maximum number of displayed lines (see {@link #setMaxLines(int)}) will be
 * modified if you change the {@link EditorInfo#TYPE_TEXT_FLAG_MULTI_LINE} flag of the input
 * type.
 *
 * @see #getInputType()
 * @see #setRawInputType(int)
 * @see android.text.InputType
 * @attr ref android.R.styleable#TextView_inputType
 */
public void setInputType (int type){
  mInputView.setInputType(type);
}

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

EditText input = new EditText(this);
input.setInputType(InputType.TYPE_CLASS_NUMBER);

代码示例来源:origin: k9mail/k-9

private void showPassword(boolean show) {
  int cursorPosition = mPasswordView.getSelectionStart();
  if (show) {
    mPasswordView.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
  } else {
    mPasswordView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
  }
  mPasswordView.setSelection(cursorPosition);
}

代码示例来源:origin: facebook/litho

private static void setInputTypeIfChanged(EditText editText, int inputType) {
 // Avoid redundant call to InputMethodManager#restartInput.
 if (inputType != editText.getInputType()) {
  editText.setInputType(inputType);
 }
}

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

protected void hideSoftKeyboard(EditText input) {
  input.setInputType(0);
  InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(input.getWindowToken(), 0);    
}

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

public class QuantityDialogFragment extends DialogFragment implements OnClickListener {

  private EditText editQuantity;

  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    editQuantity = new EditText(getActivity());
    editQuantity.setInputType(InputType.TYPE_CLASS_NUMBER);

    return new AlertDialog.Builder(getActivity()).setTitle(R.string.app_name).setMessage("Please Enter Quantity")
        .setPositiveButton("OK", this).setNegativeButton("CANCEL", null).setView(editQuantity).create();

  }

  @Override
  public void onClick(DialogInterface dialog, int position) {
    String value = editQuantity.getText().toString();
    Log.d("Quantity: ", value);
    MainActivity callingActivity = (MainActivity) getActivity();
    callingActivity.onUserSelectValue(value);
    dialog.dismiss();
  }
}

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

EditText editText = (EditText) findViewById(R.id.MyEditText);
 editText.setInputType(InputType.TYPE_CLASS_NUMBER);
 editText.setTransformationMethod(PasswordTransformationMethod.getInstance());

代码示例来源:origin: ankidroid/Anki-Android

/**
 * Update settings to show a numeric keyboard instead of the default keyboard.
 * <p>
 * This method should only be called once from the constructor.
 */
private void updateSettings() {
  // Use the number pad but still allow normal text for spaces and decimals.
  getEditText().setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_CLASS_TEXT);
}

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

alertDialog.setTitle("Values");
final EditText quantity = new EditText(SecondScan.this);
final EditText lot = new EditText(SecondScan.this);

quantity.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
lot.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);

Project=arr[0].toString();
Item=arr[1].toString();

LinearLayout ll=new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
ll.addView(quantity);
ll.addView(lot);
alertDialog.setView(ll);

alertDialog.setCancelable(false);
alertDialog.setPositiveButton("Update",  new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface dialog, int id) {
    //ACTION
  }
});

AlertDialog alert = alertDialog.create();
alert.show();

代码示例来源:origin: ACRA/acra

/**
 * creates an email prompt
 *
 * @param savedEmail the content of the prompt (usually from a saved state or settings)
 * @return the email prompt
 */
@NonNull
protected EditText getEmailPrompt(@Nullable CharSequence savedEmail) {
  final EditText userEmailView = new EditText(this);
  userEmailView.setSingleLine();
  userEmailView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
  if (savedEmail != null) {
    userEmailView.setText(savedEmail);
  } else {
    final SharedPreferences prefs = sharedPreferencesFactory.create();
    userEmailView.setText(prefs.getString(ACRA.PREF_USER_EMAIL_ADDRESS, ""));
  }
  return userEmailView;
}

代码示例来源:origin: RobotiumTech/robotium

public void run()
  {
    editText.setInputType(InputType.TYPE_NULL); 
    editText.performClick();
    dialogUtils.hideSoftKeyboard(editText, false, false);
    if(text.equals(""))
      editText.setText(text);
    else{
      editText.setText(previousText + text);
      editText.setCursorVisible(false);
    }
  }
});

代码示例来源:origin: TommyLemon/APIJSON

break;
case TYPE_PHONE:
  etEditTextInfo.setInputType(InputType.TYPE_CLASS_PHONE);
  maxEms = 11;
  break;
case TYPE_EMAIL:
  etEditTextInfo.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
  maxEms = 60;
  break;
case TYPE_WEBSITE:
  etEditTextInfo.setInputType(InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT);
  maxEms = 200;
  break;

代码示例来源:origin: TommyLemon/Android-ZBLibrary

break;
case TYPE_PHONE:
  etEditTextInfo.setInputType(InputType.TYPE_CLASS_PHONE);
  maxEms = 11;
  break;
case TYPE_EMAIL:
  etEditTextInfo.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
  maxEms = 60;
  break;
case TYPE_WEBSITE:
  etEditTextInfo.setInputType(InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT);
  maxEms = 200;
  break;

代码示例来源:origin: ankidroid/Anki-Android

/**
 * Update settings to only allow integer input and set the maximum number of digits allowed in the text field based
 * on the current value of the {@link #mMax} field.
 * <p>
 * This method should only be called once from the constructor.
 */
private void updateSettings() {
  // Only allow integer input
  getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
  // Set max number of digits
  int maxLength = String.valueOf(mMax).length();
  // Clone the existing filters so we don't override them, then append our one at the end.
  InputFilter[] filters = getEditText().getFilters();
  InputFilter[] newFilters = new InputFilter[filters.length + 1];
  System.arraycopy(filters, 0, newFilters, 0, filters.length);
  newFilters[newFilters.length - 1] = new InputFilter.LengthFilter(maxLength);
  getEditText().setFilters(newFilters);
}

代码示例来源:origin: seven332/EhViewer

String hint = getString(R.string.go_to_hint, page + 1, pages);
final EditTextDialogBuilder builder = new EditTextDialogBuilder(context, null, hint);
builder.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
final AlertDialog dialog = builder.setTitle(R.string.go_to)
    .setPositiveButton(android.R.string.ok, null)

代码示例来源:origin: cSploit/android

mEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);

代码示例来源:origin: cSploit/android

public WifiCrackDialog(String title, String message, FragmentActivity activity, WifiCrackDialogListener wifiCrackDialogListener){
 super(activity);
 mEditText = new EditText(activity);
 mEditText.setEnabled(true);
 mEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
 this.setTitle(title);
 this.setMessage(message);
 this.setView(mEditText);
 final WifiCrackDialogListener listener = wifiCrackDialogListener;
 this.setButton(BUTTON_POSITIVE, activity.getString(R.string.connect), new DialogInterface.OnClickListener(){
  public void onClick(DialogInterface dialog, int id){
   if(listener != null)
    listener.onManualConnect(mEditText.getText() + "");
  }
 });
 this.setButton(BUTTON_NEUTRAL, activity.getString(R.string.crack), new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface dialog, int id) {
   if (listener != null)
    listener.onCrack();
  }
 });
 this.setButton(BUTTON_NEGATIVE, activity.getString(R.string.cancel_dialog), new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface dialog, int id) {
   dialog.dismiss();
  }
 });
}

相关文章

微信公众号

最新文章

更多

EditText类方法