What is the difference between EditText.setInputType and setRawInputType.
I have a field that should allow for all characters, but I have a mode button that switches between numeric and alpha keyboard.
So I want the numeric keyboard when they are "part number" search mode, but alpha keyboard when they are "description" search mode.
Android OS 2.2 or later.
setRawInputType()
is usually used when you initialize the view, in a constructor of a custom view or in onCreate()
method of an activity, etc. It's the same as if you set inputType with the XML attribute android:inputType
. For example:
setContentView(R.layout.main);
mEditText = (EditText) findViewById(R.id.edit_text);
mEditText.setRawInputType(InputType.TYPE_CLASS_NUMBER);
...
In your situation to change the mode of the soft keyboard that is shown for the editor
on the fly you have to call setInputType()
which also takes care of restarting soft keyboard.
setInputType(InputType.TYPE_CLASS_NUMBER)
changes keyboard layout to numeric text
setInputType(InputType.TYPE_CLASS_TEXT)
changes keyboard layout to normal text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With