本文整理汇总了Java中android.text.InputType类的典型用法代码示例。如果您正苦于以下问题:Java InputType类的具体用法?Java InputType怎么用?Java InputType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InputType类属于android.text包,在下文中一共展示了InputType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.text.InputType; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_key_board);
mPasswordEt = (EditText) findViewById(R.id.editText2);
mPasswordEt.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int inputType = mPasswordEt.getInputType();
mPasswordEt.setInputType(InputType.TYPE_NULL);
new KeyboardUtil(KeyBoardActivity.this, KeyBoardActivity.this, mPasswordEt).showKeyboard();
mPasswordEt.setInputType(inputType);
return false;
}
});
}
示例2: updateInputMethod
import android.text.InputType; //导入依赖的package包/类
protected void updateInputMethod() {
boolean hasNumberField = mNumberField != null;
setEnabled(hasNumberField);
if (hasNumberField) {
int imeOptions = InputType.TYPE_CLASS_NUMBER;
StringBuilder allowedChars = new StringBuilder("0123456789");
if (mAllowExponent) {
allowedChars.append("e");
}
if (mNumberField.getMinimumValue() < 0) {
imeOptions |= InputType.TYPE_NUMBER_FLAG_SIGNED;
allowedChars.append("-");
}
if (!mNumberField.isInteger()) {
imeOptions |= InputType.TYPE_NUMBER_FLAG_DECIMAL;
allowedChars.append(mLocalizedDecimalSymbols.getDecimalSeparator());
}
allowedChars.append(mLocalizedDecimalSymbols.getGroupingSeparator());
setImeOptions(imeOptions);
setKeyListener(DigitsKeyListener.getInstance(allowedChars.toString()));
}
}
示例3: onCreate
import android.text.InputType; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
OTPView otpView = (OTPView) findViewById(R.id.otpView);
otpView.setTextColor(R.color.colorAccent)
.setHintColor(R.color.colorAccent)
.setCount(7)
.setInputType(InputType.TYPE_CLASS_NUMBER)
.setViewsPadding(16)
.setListener(new OTPListener() {
@Override
public void otpFinished(String otp) {
Toast.makeText(MainActivity.this, "OTP finished, the otp is " + otp, Toast.LENGTH_SHORT).show();
}
})
.fillLayout();
}
示例4: init
import android.text.InputType; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
protected void init() {
eyeNo = resources.getDrawable(R.drawable.eye_no, null);
eyeYes = resources.getDrawable(R.drawable.eye_yes, null);
error = (TextView) dialog.findViewById(R.id.error);
editText = (EditText) dialog.findViewById(R.id.edit);
eye = (ImageView) dialog.findViewById(R.id.eye);
eyeRegion = dialog.findViewById(R.id.eye_region);
clear = (RelativeLayout) dialog.findViewById(R.id.rel_clear);
clear.setVisibility(View.GONE);
clear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
editText.setText("");
}
});
eyeRegion.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(pwdVisible){
pwdVisible = false;
eye.setImageDrawable(eyeNo);
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
}else{
pwdVisible = true;
eye.setImageDrawable(eyeYes);
editText.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
}
editText.setSelection(editText.getText().length());
Log.d(TAG, "onClick:"+pwdVisible);
}
});
editText.addTextChangedListener(textWatcher);
}
示例5: onCreateActions
import android.text.InputType; //导入依赖的package包/类
@Override
public void onCreateActions(@NonNull List<GuidedAction> actions, Bundle savedInstanceState) {
GuidedAction enterUsername = new GuidedAction.Builder()
.title(getString(R.string.pref_title_username))
.descriptionEditable(true)
.build();
GuidedAction enterPassword = new GuidedAction.Builder()
.title(getString(R.string.pref_title_password))
.descriptionEditable(true)
.descriptionInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT)
.build();
GuidedAction login = new GuidedAction.Builder()
.id(CONTINUE)
.title(getString(R.string.guidedstep_continue))
.build();
actions.add(enterUsername);
actions.add(enterPassword);
actions.add(login);
}
示例6: showAddToFriendsMessageDialog
import android.text.InputType; //导入依赖的package包/类
@Override
public void showAddToFriendsMessageDialog() {
new InputTextDialog.Builder(getActivity())
.setInputType(InputType.TYPE_CLASS_TEXT)
.setTitleRes(R.string.add_to_friends)
.setHint(R.string.attach_message)
.setAllowEmpty(true)
.setCallback(newValue -> getPresenter().fireAddToFrindsClick(newValue))
.show();
}
示例7: setTransport
import android.text.InputType; //导入依赖的package包/类
public void setTransport(TransportOption transport) {
final boolean useSystemEmoji = TextSecurePreferences.isSystemEmojiPreferred(getContext());
int imeOptions = (getImeOptions() & ~EditorInfo.IME_MASK_ACTION) | EditorInfo.IME_ACTION_SEND;
int inputType = getInputType();
if (isLandscape()) setImeActionLabel(transport.getComposeHint(), EditorInfo.IME_ACTION_SEND);
else setImeActionLabel(null, 0);
if (useSystemEmoji) {
inputType = (inputType & ~InputType.TYPE_MASK_VARIATION) | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE;
}
setInputType(inputType);
setImeOptions(imeOptions);
setHint(transport.getComposeHint(),
transport.getSimName().isPresent()
? getContext().getString(R.string.conversation_activity__from_sim_name, transport.getSimName().get())
: null);
}
示例8: getType
import android.text.InputType; //导入依赖的package包/类
private int getType(EditType editType) {
int type;
switch (editType) {
case phone:
type = InputType.TYPE_CLASS_PHONE;
break;
case number:
type = InputType.TYPE_CLASS_NUMBER;
break;
case numberDecimal:
type = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL;
break;
case textPassword:
type = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
break;
case numberPassword:
type = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD;
break;
default:
type = InputType.TYPE_CLASS_TEXT;
}
return type;
}
示例9: setInputType
import android.text.InputType; //导入依赖的package包/类
public UDEditText setInputType(CharSequence text) {
EditText view = getView();
if (view != null) {
if (text.equals("number")) {
view.setInputType(InputType.TYPE_CLASS_NUMBER);
mType = "number";
} else if(text.equals("password")) {
view.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
mType = "password";
} else if(text.equals("visible_password")) {
view.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
mType = "visible_password";
} else {
view.setInputType(InputType.TYPE_CLASS_TEXT);
mType = "text";
}
}
return this;
}
示例10: testMultiline
import android.text.InputType; //导入依赖的package包/类
@Test
public void testMultiline() {
ReactEditText view = mManager.createViewInstance(mThemedContext);
mManager.updateProperties(view, buildStyles());
assertThat(view.getInputType() & InputType.TYPE_TEXT_FLAG_MULTI_LINE).isZero();
mManager.updateProperties(view, buildStyles("multiline", false));
assertThat(view.getInputType() & InputType.TYPE_TEXT_FLAG_MULTI_LINE).isZero();
mManager.updateProperties(view, buildStyles("multiline", true));
assertThat(view.getInputType() & InputType.TYPE_TEXT_FLAG_MULTI_LINE).isNotZero();
mManager.updateProperties(view, buildStyles("multiline", null));
assertThat(view.getInputType() & InputType.TYPE_TEXT_FLAG_MULTI_LINE).isZero();
}
示例11: fillLayout
import android.text.InputType; //导入依赖的package包/类
@Override
public void fillLayout(final SipProfile account) {
super.fillLayout(account);
accountUsername.getEditText().setInputType(InputType.TYPE_CLASS_TEXT);
//Get wizard specific row
customWizardText = (TextView) parent.findViewById(R.id.custom_wizard_text);
customWizard = (LinearLayout) parent.findViewById(R.id.custom_wizard_row);
settingsContainer = (ViewGroup) parent.findViewById(R.id.settings_container);
validationBar = (ViewGroup) parent.findViewById(R.id.validation_bar);
updateAccountInfos(account);
extAccCreator = new AccountCreationWebview(parent, "https://m.ippi.fr/subscribe/android.php", this);
}
示例12: setDisplayedValues
import android.text.InputType; //导入依赖的package包/类
/**
* Sets the values to be displayed.
*
* @param displayedValues The displayed values.
* <p>
* <strong>Note:</strong> The length of the displayed values array
* must be equal to the range of selectable numbers which is equal to
* {@link #getMaxValue()} - {@link #getMinValue()} + 1.
*/
public void setDisplayedValues(String[] displayedValues) {
if (mDisplayedValues == displayedValues) {
return;
}
mDisplayedValues = displayedValues;
if (mDisplayedValues != null) {
// Allow text entry rather than strictly numeric entry.
mInputText.setRawInputType(InputType.TYPE_CLASS_TEXT
| InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
} else {
mInputText.setRawInputType(InputType.TYPE_CLASS_NUMBER);
}
updateInputTextView();
initializeSelectorWheelIndices();
tryComputeMaxWidth();
}
示例13: initializeViews
import android.text.InputType; //导入依赖的package包/类
private void initializeViews(Note note) {
String title = note.getTitle();
String text = note.getText();
titleEditText.setFilters(new InputFilter[]{new InputFilter.AllCaps()});
titleEditText.setRawInputType(InputType.TYPE_CLASS_TEXT);
if (title == null && text == null) {
getActivity().getWindow()
.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Util.showKeyboardFrom(getContext(), textEditText);
} else {
titleEditText.setText(title);
textEditText.setText(text);
}
setColor(note.getColor());
updateDateEditedTextView();
}
示例14: onSelectionChanged
import android.text.InputType; //导入依赖的package包/类
@Override
protected void onSelectionChanged(int selStart, int selEnd) {
super.onSelectionChanged(selStart, selEnd);
if (getLayout() == null)
return;
String line = getText().subSequence(getLayout().getLineStart(getLayout()
.getLineForOffset(selStart)), selEnd).toString();
boolean isPassword = getPasswordStart(line) != -1;
boolean wasPassword = (getInputType() & InputType.TYPE_TEXT_VARIATION_PASSWORD) != 0;
if (isPassword && !wasPassword) {
Typeface tf = getTypeface();
setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE |
InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
setTypeface(tf);
setSelection(selStart, selEnd);
} else if (!isPassword && wasPassword) {
createPasswordSpans();
setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
}
}
示例15: createDialogInput
import android.text.InputType; //导入依赖的package包/类
/**
* Creates a dialog to type in text
*/
public void createDialogInput(String header, String content, MaterialDialog.InputCallback callback, MaterialDialog.SingleButtonCallback buttonCallback) {
new MaterialDialog.Builder(mContext)
.positiveText(R.string.Ok)
.negativeText(R.string.Cancel)
//.neutralText(R.string.attach_media)
.autoDismiss(false)
.onAny(buttonCallback)
.buttonRippleColorRes(R.color.colorAccent)
.positiveColorRes(R.color.colorStateBlue)
.negativeColorRes(R.color.colorStateOrange)
.theme(app_prefs.isLightTheme()?Theme.LIGHT:Theme.DARK)
.title(header)
.content(content)
.inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE | InputType.TYPE_TEXT_FLAG_MULTI_LINE)
.input(mContext.getString(R.string.text_enter_text), null, callback)
.show();
}