Java Code Examples for android.widget.EditText#setRawInputType()
The following examples show how to use
android.widget.EditText#setRawInputType() .
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: NumberPicker.java From financisto with GNU General Public License v2.0 | 6 votes |
public NumberPicker(Context context, AttributeSet attrs, int defStyle) { super(context, attrs); setOrientation(VERTICAL); LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.number_picker, this, true); mHandler = new Handler(); InputFilter inputFilter = new NumberPickerInputFilter(); mNumberInputFilter = new NumberRangeKeyListener(); mIncrementButton = (NumberPickerButton) findViewById(R.id.increment); mIncrementButton.setOnClickListener(this); mIncrementButton.setOnLongClickListener(this); mIncrementButton.setNumberPicker(this); mDecrementButton = (NumberPickerButton) findViewById(R.id.decrement); mDecrementButton.setOnClickListener(this); mDecrementButton.setOnLongClickListener(this); mDecrementButton.setNumberPicker(this); mText = (EditText) findViewById(R.id.timepicker_input); mText.setOnFocusChangeListener(this); mText.setFilters(new InputFilter[] {inputFilter}); mText.setRawInputType(InputType.TYPE_CLASS_NUMBER); if (!isEnabled()) { setEnabled(false); } }
Example 2
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 3
Source File: NumberPicker.java From screenstandby with GNU General Public License v2.0 | 6 votes |
public NumberPicker(Context context, AttributeSet attrs, int defStyle) { super(context, attrs); setOrientation(VERTICAL); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.number_picker, this, true); mHandler = new Handler(); InputFilter inputFilter = new NumberPickerInputFilter(); mNumberInputFilter = new NumberRangeKeyListener(); mIncrementButton = (NumberPickerButton) findViewById(R.id.increment); mIncrementButton.setOnClickListener(this); mIncrementButton.setOnLongClickListener(this); mIncrementButton.setNumberPicker(this); mDecrementButton = (NumberPickerButton) findViewById(R.id.decrement); mDecrementButton.setOnClickListener(this); mDecrementButton.setOnLongClickListener(this); mDecrementButton.setNumberPicker(this); mText = (EditText) findViewById(R.id.timepicker_input); mText.setOnFocusChangeListener(this); mText.setFilters(new InputFilter[] {inputFilter}); mText.setRawInputType(InputType.TYPE_CLASS_NUMBER); if (!isEnabled()) { setEnabled(false); } }
Example 4
Source File: TextEntryElement.java From sana.mobile with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * {@inheritDoc} */ @Override protected View createView(Context c) { et = new EditText(c); et.setBackgroundResource(R.drawable.oval); et.setTextColor(c.getResources() .getColorStateList(R.color.primary_text_holo_light)); et.setText(answer); et.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); if (!NumericType.NONE.equals(numericType)) { KeyListener listener = getKeyListenerForType(numericType); if (listener != null) et.setKeyListener(listener); } else { et.setRawInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | TYPE_TEXT_FLAG_NO_SUGGESTIONS); } return encapsulateQuestion(c, et); }
Example 5
Source File: LabelDetailsFragment.java From science-journal with Apache License 2.0 | 5 votes |
protected void setupCaption(View rootView) { caption = (EditText) rootView.findViewById(R.id.caption); caption.setText(originalLabel.getCaptionText()); caption.setImeOptions(EditorInfo.IME_ACTION_DONE); caption.setRawInputType(InputType.TYPE_CLASS_TEXT); caption.setOnEditorActionListener( (textView, i, keyEvent) -> { if (i == EditorInfo.IME_ACTION_DONE) { caption.clearFocus(); caption.setFocusable(false); } return false; }); caption.setOnTouchListener( (v, motionEvent) -> { caption.setFocusableInTouchMode(true); caption.requestFocus(); return false; }); caption.setEnabled(false); experiment .firstElement() .subscribe( experiment -> { caption.setEnabled(true); // Move the cursor to the end caption.post(() -> caption.setSelection(caption.getText().toString().length())); saved .happens() .subscribe(o -> saveCaptionChanges(experiment, caption.getText().toString())); }); }
Example 6
Source File: AnagramsActivity.java From jterm-cswithandroid with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_anagrams); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); AssetManager assetManager = getAssets(); try { InputStream inputStream = assetManager.open("words.txt"); dictionary = new AnagramDictionary(inputStream); } catch (IOException e) { Toast toast = Toast.makeText(this, "Could not load dictionary", Toast.LENGTH_LONG); toast.show(); } // Set up the EditText box to process the content of the box when the user hits 'enter' final EditText editText = (EditText) findViewById(R.id.editText); editText.setRawInputType(InputType.TYPE_CLASS_TEXT); editText.setImeOptions(EditorInfo.IME_ACTION_GO); editText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; if (actionId == EditorInfo.IME_ACTION_GO) { processWord(editText); handled = true; } return handled; } }); }
Example 7
Source File: AnagramsActivity.java From jterm-cswithandroid with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_anagrams); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); AssetManager assetManager = getAssets(); try { InputStream inputStream = assetManager.open("words.txt"); dictionary = new AnagramDictionary(inputStream); } catch (IOException e) { Toast toast = Toast.makeText(this, "Could not load dictionary", Toast.LENGTH_LONG); toast.show(); } // Set up the EditText box to process the content of the box when the user hits 'enter' final EditText editText = (EditText) findViewById(R.id.editText); editText.setRawInputType(InputType.TYPE_CLASS_TEXT); editText.setImeOptions(EditorInfo.IME_ACTION_GO); editText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; if (actionId == EditorInfo.IME_ACTION_GO) { processWord(editText); handled = true; } return handled; } }); }
Example 8
Source File: ViewUtils.java From ResearchStack with Apache License 2.0 | 5 votes |
public static void disableSoftInputFromAppearing(EditText editText) { if (Build.VERSION.SDK_INT >= 11) { editText.setRawInputType(InputType.TYPE_CLASS_TEXT); editText.setTextIsSelectable(true); } else { editText.setRawInputType(InputType.TYPE_NULL); editText.setFocusable(true); } }
Example 9
Source File: PolicyManagementFragment.java From android-testdpc with Apache License 2.0 | 5 votes |
/** * For user removal: * Shows a prompt for a user serial number. The associated user will be removed. */ private void showRemoveUserPromptLegacy() { if (getActivity() == null || getActivity().isFinishing()) { return; } View view = LayoutInflater.from(getActivity()).inflate(R.layout.simple_edittext, null); final EditText input = (EditText) view.findViewById(R.id.input); input.setHint(R.string.enter_user_id); input.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED); new AlertDialog.Builder(getActivity()) .setTitle(R.string.remove_user) .setView(view) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { boolean success = false; long serialNumber = -1; try { serialNumber = Long.parseLong(input.getText().toString()); UserHandle userHandle = mUserManager .getUserForSerialNumber(serialNumber); if (userHandle != null) { success = mDevicePolicyManager .removeUser(mAdminComponentName, userHandle); } } catch (NumberFormatException e) { // Error message is printed in the next line. } showToast(success ? R.string.user_removed : R.string.failed_to_remove_user); } }) .show(); }
Example 10
Source File: FormEditNumberFieldCell.java From QMBForm with MIT License | 5 votes |
@Override protected void init() { super.init(); EditText editView = getEditView(); editView.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); }
Example 11
Source File: FormEditTextFieldCell.java From QMBForm with MIT License | 5 votes |
@Override protected void init() { super.init(); mEditView = (EditText) findViewById(R.id.editText); mEditView.setRawInputType(InputType.TYPE_CLASS_TEXT); setStyleId(mEditView, CellDescriptor.APPEARANCE_TEXT_VALUE, CellDescriptor.COLOR_VALUE); }
Example 12
Source File: ConfigureStandupTimer.java From UltimateAndroid with Apache License 2.0 | 5 votes |
private View createMeetingLengthTextBox() { meetingLengthEditText = new EditText(this); meetingLengthEditText.setGravity(Gravity.CENTER); meetingLengthEditText.setKeyListener(new DigitsKeyListener()); meetingLengthEditText.setRawInputType(InputType.TYPE_CLASS_PHONE); meetingLengthEditText.setLayoutParams(new LayoutParams(dipsToPixels(60), LayoutParams.WRAP_CONTENT)); meetingLengthEditText.setText(Integer.toString(meetingLength)); meetingLengthEditText.setLines(1); meetingLengthSpinner = null; return meetingLengthEditText; }
Example 13
Source File: ConfigureStandupTimer.java From UltimateAndroid with Apache License 2.0 | 5 votes |
private View createMeetingLengthTextBox() { meetingLengthEditText = new EditText(this); meetingLengthEditText.setGravity(Gravity.CENTER); meetingLengthEditText.setKeyListener(new DigitsKeyListener()); meetingLengthEditText.setRawInputType(InputType.TYPE_CLASS_PHONE); meetingLengthEditText.setLayoutParams(new LayoutParams(dipsToPixels(60), LayoutParams.WRAP_CONTENT)); meetingLengthEditText.setText(Integer.toString(meetingLength)); meetingLengthEditText.setLines(1); meetingLengthSpinner = null; return meetingLengthEditText; }
Example 14
Source File: NoteActivity.java From DragLinearLayout with MIT License | 4 votes |
@Override public void onFocusChange(View v, boolean hasFocus) { setImeVisibility(noteContainer, hasFocus); EditText editText = (EditText) v; final int index = getNoteIndex(note); if(hasFocus){ editText.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT); } else { if(editText.length() > 0){ ((ImageView)note.findViewById(R.id.noteIcon)).setImageResource(R.drawable.ic_drag); noteContainer.setViewDraggable(note, note.findViewById(R.id.noteIconContainer)); if(index < noteCount){ // note at index set to new value } else { // new note added at index noteCount++; } editText.setHint(R.string.note_complete_prompt); } else { if(index < noteCount){ // existing note set blank } else if(index < getLastNoteIndex()){ // too many trailing blank notes, remove last one final View noteToDelete = noteContainer.getChildAt(firstNoteIndex + index + 1); noteToDelete.findViewById(R.id.noteText).setEnabled(false); // disable further editing ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(noteToDelete, "alpha", 1, 0); ObjectAnimator xAnimator = ObjectAnimator.ofFloat(noteToDelete, "x", noteToDelete.getLeft(), noteToDelete.getLeft() + 30); AnimatorSet set = new AnimatorSet(); set.playTogether(alphaAnimator, xAnimator); set.setDuration(200); set.addListener(new AnimatorListenerAdapter(){ @Override public void onAnimationEnd(Animator animation) { noteContainer.removeView(noteToDelete); } }); set.start(); } } editText.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); } }