Java Code Examples for android.widget.EditText#setInputType()
The following examples show how to use
android.widget.EditText#setInputType() .
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: HCActivity.java From styT with Apache License 2.0 | 6 votes |
public void showEditTextDialog(Context context, String title, final int itemPosition) { final EditText edit = new EditText(context); //设置只能输入小数 edit.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); edit.setText(items.get(itemPosition).get("delay") + ""); new AlertDialog.Builder(context) .setTitle(title) .setView(edit) .setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface p1, int p2) { // TODO: Implement this method items.get(itemPosition).put("delay", edit.getText().toString()); adapter.notifyDataSetChanged(); } }) .setNegativeButton("取消", null).show(); }
Example 2
Source File: RxTool.java From RxTools-master with Apache License 2.0 | 6 votes |
public static void setEdDecimal(EditText editText, int count) { if (count < 1) { count = 1; } editText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_CLASS_NUMBER); //设置字符过滤 final int finalCount = count; editText.setFilters(new InputFilter[]{new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { if (source.equals(".") && dest.toString().length() == 0) { return "0."; } if (dest.toString().contains(".")) { int index = dest.toString().indexOf("."); int mlength = dest.toString().substring(index).length(); if (mlength == finalCount) { return ""; } } return null; } }}); }
Example 3
Source File: Utils.java From BigApp_Discuz_Android with Apache License 2.0 | 6 votes |
public static void closeSoftKeyboard(Activity context,EditText editText) { if (android.os.Build.VERSION.SDK_INT <= 10) {//4.0以下 danielinbiti editText.setInputType(InputType.TYPE_NULL); } else { context.getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); try { Class<EditText> cls = EditText.class; Method setShowSoftInputOnFocus; setShowSoftInputOnFocus = cls.getMethod("setShowSoftInputOnFocus", boolean.class); setShowSoftInputOnFocus.setAccessible(true); setShowSoftInputOnFocus.invoke(editText, false); } catch (Exception e) { e.printStackTrace(); } } }
Example 4
Source File: ClientWebView.java From habpanelviewer with GNU General Public License v3.0 | 6 votes |
public void enterUrl(Context ctx) { AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setTitle("Enter URL"); final EditText input = new EditText(ctx); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); input.setText(getUrl()); input.selectAll(); builder.setView(input); builder.setPositiveButton("OK", (dialog, which) -> { String url = input.getText().toString(); mKioskMode = isHabPanelUrl(url) && url.toLowerCase().contains("kiosk=on"); loadUrl(url); }); builder.setNegativeButton("Cancel", (dialog, which) -> dialog.cancel()); builder.show(); }
Example 5
Source File: GoToPageDialogFragment.java From Hentoid with Apache License 2.0 | 6 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { EditText input = new EditText(getContext()); input.setInputType(InputType.TYPE_CLASS_NUMBER); input.setRawInputType(Configuration.KEYBOARD_12KEY); DialogInterface.OnClickListener positive = (dialog, whichButton) -> { if (input.getText().length() > 0) parent.goToPage(Integer.parseInt(input.getText().toString())); }; AlertDialog materialDialog = new MaterialAlertDialogBuilder(requireContext()) .setView(input) .setPositiveButton(android.R.string.ok, positive) .setNegativeButton(android.R.string.cancel, null) .create(); materialDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); return materialDialog; }
Example 6
Source File: ConvKeysFragment.java From Equate with GNU General Public License v3.0 | 6 votes |
private void createCustomUnitDialog() { AlertDialog.Builder builder = new AlertDialog. Builder(getActivity()); builder.setTitle("Create New Unit:"); Context context = getActivity(); final EditText filterEditText = new EditText(context); final TextView textView = new TextView(context); filterEditText.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_search_white, 0, 0, 0); filterEditText.setInputType(InputType.TYPE_CLASS_TEXT); filterEditText.setHint("ie Dollars"); textView.setText("Unit Name:"); LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.VERTICAL); layout.addView(textView); layout.addView(filterEditText); builder.setView(layout); builder.setNegativeButton(android.R.string.cancel, null); AlertDialog alert = builder.create(); alert.show(); }
Example 7
Source File: LockActivity.java From AppLocker with Apache License 2.0 | 5 votes |
protected void setupEditText(EditText editText) { editText.setInputType(InputType.TYPE_NULL); editText.setFilters(filters); editText.setOnTouchListener(touchListener); editText.setTransformationMethod(PasswordTransformationMethod .getInstance()); }
Example 8
Source File: FormEditURLFieldCell.java From QMBForm with MIT License | 5 votes |
@Override protected void init() { super.init(); EditText editView = getEditView(); editView.setInputType(InputType.TYPE_TEXT_VARIATION_URI); }
Example 9
Source File: MainActivity.java From shadowsocks-android-java with Apache License 2.0 | 5 votes |
private void showProxyUrlInputDialog() { final EditText editText = new EditText(this); editText.setInputType(InputType.TYPE_TEXT_VARIATION_URI); editText.setHint(getString(R.string.config_url_hint)); editText.setText(readProxyUrl()); new AlertDialog.Builder(this) .setTitle(R.string.config_url) .setView(editText) .setPositiveButton(R.string.btn_ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (editText.getText() == null) { return; } String ProxyUrl = editText.getText().toString().trim(); if (isValidUrl(ProxyUrl)) { setProxyUrl(ProxyUrl); textViewProxyUrl.setText(ProxyUrl); } else { Toast.makeText(MainActivity.this, R.string.err_invalid_url, Toast.LENGTH_SHORT).show(); } } }) .setNegativeButton(R.string.btn_cancel, null) .show(); }
Example 10
Source File: ViewerActivityController.java From document-viewer with GNU General Public License v3.0 | 5 votes |
public void askPassword(final String fileName, final int promtId) { final EditText input = new AppCompatEditText(getManagedComponent()); input.setSingleLine(true); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); final ActionDialogBuilder builder = new ActionDialogBuilder(getManagedComponent(), this); builder.setTitle(fileName).setMessage(promtId).setView(input); builder.setPositiveButton(R.id.actions_redecodingWithPassword, new EditableValue("input", input)); builder.setNegativeButton(R.id.mainmenu_close).show(); }
Example 11
Source File: PinCodeActivity.java From product-emm with Apache License 2.0 | 5 votes |
private void setPINCode(){ evInput = new EditText(PinCodeActivity.this); alertDialog = CommonDialogUtils .getAlertDialogWithTwoButtonAndEditView(PinCodeActivity.this, getResources() .getString( R.string.title_head_confirm_pin), getResources() .getString( R.string.button_ok), getResources() .getString( R.string.button_cancel), dialogClickListener, dialogClickListener, evInput); final AlertDialog dialog = alertDialog.create(); dialog.show(); // Overriding default positive button behavior to keep the // dialog open, if PINS don't match. dialog.getButton(AlertDialog.BUTTON_POSITIVE) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (evPin.getText().toString() .equals(evInput.getText().toString())) { savePin(); dialog.dismiss(); } else { evInput.setError(getResources().getString( R.string.validation_pin_confirm)); } } }); evInput.setInputType(InputType.TYPE_CLASS_NUMBER); evInput.setTransformationMethod(new PasswordTransformationMethod()); }
Example 12
Source File: EditCommandAliasActivity.java From revolution-irc with GNU General Public License v3.0 | 5 votes |
private static void setEditTextDisabled(EditText editText) { editText.setInputType(InputType.TYPE_NULL); editText.setTextIsSelectable(true); editText.setKeyListener(null); editText.setBackgroundResource(R.drawable.edit_text_readonly); int color = StyledAttributesHelper.getColor(editText.getContext(), android.R.attr.textColorSecondary, 0); ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(color)); ((ViewGroup) editText.getParent()).setAddStatesFromChildren(false); }
Example 13
Source File: ReactTextInputLocalData.java From react-native-GPay with MIT License | 5 votes |
public void apply(EditText editText) { editText.setText(mText); editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); editText.setMinLines(mMinLines); editText.setMaxLines(mMaxLines); editText.setInputType(mInputType); editText.setHint(mPlaceholder); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { editText.setBreakStrategy(mBreakStrategy); } }
Example 14
Source File: WifiAuthenticatorActivity.java From WiFiAfterConnect with Apache License 2.0 | 5 votes |
private void addField (HtmlInput field) { Log.d(Constants.TAG, "adding ["+field.getName() + "], type = [" + field.getType()+"]"); TextView labelView = new TextView(this); labelView.setText(field.getName()); int textSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, (float) 8, getResources().getDisplayMetrics()); labelView.setTextSize (textSize); EditText editView = new EditText(this); editView.setInputType(field.getAndroidInputType()); editView.setText (field.getValue()); editView.setTag(field.getName()); editView.setFocusable (true); edits.add(editView); editView.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { onAuthenticateClick(v); } return false; } }); TableRow row = new TableRow (this); fieldsTable.addView (row, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,TableLayout.LayoutParams.WRAP_CONTENT)); TableRow.LayoutParams labelLayout = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT); int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) 5, getResources().getDisplayMetrics()); labelLayout.setMargins(margin, margin, margin, margin); row.addView(labelView, labelLayout); TableRow.LayoutParams editLayout = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.WRAP_CONTENT); row.addView(editView, editLayout); }
Example 15
Source File: DialogHelper.java From javaide with GNU General Public License v3.0 | 5 votes |
public static void initFilenameInputDialog(MaterialDialog show) { final EditText editText = show.getInputEditText(); editText.setSingleLine(); editText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER); editText.setImeOptions(EditorInfo.IME_ACTION_DONE); // create an initial filename to suggest to the user String filename = createLogFilename(); editText.setText(filename); // highlight everything but the .txt at the end editText.setSelection(0, filename.length() - 4); }
Example 16
Source File: InternalHelper.java From SimpleAlertDialog-for-Android with Apache License 2.0 | 5 votes |
private void setEditText(Bundle args, SimpleAlertDialog dialog) { if (!has(args, SimpleAlertDialog.ARG_EDIT_TEXT_INITIAL_TEXT) || !has(args, SimpleAlertDialog.ARG_EDIT_TEXT_INPUT_TYPE)) { return; } View view = LayoutInflater.from(getActivity()).inflate(R.layout.sad__dialog_view_editor, null); EditText editText = (EditText) view.findViewById(android.R.id.text1); editText.setText(args.getCharSequence(SimpleAlertDialog.ARG_EDIT_TEXT_INITIAL_TEXT)); editText.setInputType(args.getInt(SimpleAlertDialog.ARG_EDIT_TEXT_INPUT_TYPE)); dialog.setView(view); }
Example 17
Source File: FormEditPasswordFieldCell.java From QMBForm with MIT License | 5 votes |
@Override protected void init() { super.init(); EditText editView = getEditView(); editView.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); editView.setTransformationMethod(PasswordTransformationMethod.getInstance()); }
Example 18
Source File: EditableInputView.java From fastnfitness with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected void editDialog(Context context) { if (!mActivateDialog) return; if (mCustomerDialogBuilder != null) { mCustomerDialogBuilder.customerDialogBuilder(this).show(); } else { if ((valueTextView.getInputType() & InputType.TYPE_CLASS_DATETIME) > 0) { Calendar calendar = Calendar.getInstance(); calendar.setTime(DateConverter.localDateStrToDate(getText(), getContext())); int day = calendar.get(Calendar.DAY_OF_MONTH); int month = calendar.get(Calendar.MONTH); int year = calendar.get(Calendar.YEAR); DatePickerDialog datePickerDialog = new DatePickerDialog( getContext(), this, year, month, day); datePickerDialog.show(); } else { final EditText editText = new EditText(context); editText.setText(mTextValue); editText.setGravity(Gravity.CENTER); editText.setInputType(textViewInputType); editText.requestFocus(); LinearLayout linearLayout = new LinearLayout(context.getApplicationContext()); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(editText); final SweetAlertDialog dialog = new SweetAlertDialog(context, SweetAlertDialog.NORMAL_TYPE) .setTitleText(mTitle) .setCancelText(getContext().getString(R.string.global_cancel)) .setHideKeyBoardOnDismiss(true) .setCancelClickListener(sDialog -> { editText.clearFocus(); Keyboard.hide(context, editText); sDialog.dismissWithAnimation();}) .setConfirmClickListener(sDialog -> { editText.clearFocus(); Keyboard.hide(context, editText); setText(editText.getText().toString()); sDialog.dismissWithAnimation(); if (mConfirmClickListener != null) mConfirmClickListener.onTextChanged(EditableInputView.this); }); dialog.setOnDismissListener(sDialog -> { rootView.requestFocus(); InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Activity.INPUT_METHOD_SERVICE); if ( imm !=null) imm.hideSoftInputFromWindow(rootView.getWindowToken(), 0);}); //Keyboard.hide(context, editText);}); dialog.setOnShowListener(sDialog -> { editText.requestFocus(); Keyboard.show(context, editText); }); dialog.setCustomView(linearLayout); dialog.show(); } } }
Example 19
Source File: KeyBoardUtil.java From AndroidBasicProject with MIT License | 4 votes |
/** * 切换为英文输入模式 */ public static void changeToEnglishInputType(EditText editText) { editText.setInputType(EditorInfo.TYPE_TEXT_VARIATION_URI); }
Example 20
Source File: PPopupDialogFragment.java From PHONK with GNU General Public License v3.0 | 4 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(mTitle); builder.setMessage(mDescription); MLog.d(TAG, "creating a dialog"); final ReturnObject r = new ReturnObject(); // enable this if (mInputText != null) { MLog.d(TAG, "input"); mInput = new EditText(getActivity()); mInput.setInputType(InputType.TYPE_CLASS_TEXT); mInput.setHint(mInputText); builder.setView(mInput, 20, 20, 20, 20); // builder.setView(mInput); } if (mChoice != null) { MLog.d(TAG, "choice"); builder.setItems(mChoice, (dialog, which) -> { MLog.d(TAG, "choice " + mChoice[which]); r.put("answer", mChoice[which]); r.put("answerId", which); mCallback.event(r); dismiss(); }); } if (mMultichoice != null) { MLog.d(TAG, "multichoice"); builder.setMultiChoiceItems(mMultichoice, mMultichoiceState, (dialog, which, isChecked) -> mMultichoiceState[which] = isChecked ); } // only show ok if we dont have a selectable list builder.setPositiveButton(mOk, (dialog, which) -> { if (mCallback != null) { r.put("accept", true); if (mMultichoiceState != null) r.put("choices", mMultichoiceState); if (mInput != null) r.put("answer", mInput.getText().toString()); mCallback.event(r); } }); builder.setNegativeButton(mCancel, (dialog, which) -> { r.put("accept", false); if (mCallback != null) mCallback.event(r); dismiss(); }); return builder.create(); }