I have a problem with TextEdit,
if I do editText.setInputType(InputType.TYPE_NONE); the user is not able to type anything.
Anyway, if there is a physical keyboard attached, then the user can type by using it (of course the soft keyboard doesn't work).
Is there any way to fully disable editing on a EditText?
PS: I need to do that programmatically at runtime
Try
android:editable="false"
in xml layout file
android:editable="false" is deprecated ,prefer not to use it.
Another solution to this that I used is given below
first_password_EditTextBox = (EditText) findViewById(R.id.editText1);
first_password_EditTextBox.setEnabled(false);
Related
Is there a way to get a comma for edittext instead of dot. My Keyboard is german, device is samsung.
looking for solution via XML not extra listeners.
So far i have tried
1.
android:digits="0123456789,"
android:inputType="number"
android:digits="0123456789,"
android:inputType="numberDecimal"
android:inputType="numberDecimal"
nothing seems to work, and I still get dot. I have gone through other similar questions but they suggest managing it by adding listener to edittexts. I have a lot of editText and it will be much additional/unnecessary work. There should be an XML simple solution to this.
Also tried
val input = EditText(requireContext())
input.keyListener = DigitsKeyListener.getInstance("0123456789.,")
EditText input = new EditText(THE_CONTEXT);
input.setKeyListener(DigitsKeyListener.getInstance("0123456789,"));
How can I disable spelling corrections in an EditText's soft-keyboard programmatically in Android? The user can disable it from settings, but I need to disable it in my application.
Is there any way to do this?
Set this in your layout's xml for your EditText:
android:inputType="textNoSuggestions"
Or call setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) in your Activity'
If you need to support API 4 and below, use android:inputType="textFilter"
If setting:
android:inputType="textNoSuggestions"
still doesn't work (and your text field is small), a quick work-around is to use:
android:inputType="textVisiblePassword"
I have an EditText in Android configured for the number keyboard, and I would like the keyboard's button to say "next", while mine is saying "done".
How can I change that?
I already tried:
<com.innovattic.font.FontEditText
style="#style/CadastroTextBoxStyle"
android:hint="CEP"
android:id="#+id/etCEP"
android:inputType="number"
android:singleLine="true"
android.imeOptions="actionNext" />
And also this:
etCEP.setImeActionLabel("Next", KeyEvent.KEYCODE_ENTER);
But it still says done.
What else can I do?
Thanks
As can be seen in Specifying the Input Method Type, you do not need to call TextView.setImeActionLabel(CharSequence, int) and you have to instead just provide a android:imeOptions value such as actionSend or actionNext in XML attributes to change the label accordingly.
This is not working for you because you have mistyped : as . in your attributes. Switching those out should fix your issue in no time.
In my android application, I have some EditTexts. Those EditTexts will serve as password fields, but I've not marked them as password fields in the attributes, so that the font of hint text matches the font of hint in normal EditText widgets.
The problem I have though is that the password is revealed in the keyboard suggestion while it is typed, although it is hidden as I've used:
EditText.setTransformationMethod(new PasswordTransformationMethod());
What should I do to disable those suggestions?
I had already fixed it, but didn't have time to come and answer the question.
For anyone who is struggling with this, adding the following attribute to the EditText will work:
android:inputType="textNoSuggestions"
Did you use android:inputType="textPassword"
and android:password="true"?
My EditText needs to accept input consisting of partial words, names, etc. At least on my HTC Desire, this is difficult since the keyboard wants to suggest and/or correct some entries (e.g., changes "gor" to "for"). I tried setting textNoSuggestions on the view, but that doesn't fix it.
Any simple solution to this?
Try this:
android:inputType="textFilter"
If that doesn't work, try:
android:inputType="textFilter|textNoSuggestions"
You can do this from the code. Set the input type of the EditText like below:
txtEmail = (EditText) findViewById(R.id.txtEmail);
txtEmail.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
For a list of all the available input type options see
http://developer.android.com/reference/android/text/InputType.html
The other suggestions are correct, but SwiftKey has decided it will ignore the inputtype values "in response to user requests". While I agree this is a bad idea since it contradicts the Google guidelines and developers usually have a good reason for disabling auto-correction (like username fields, family names and so on), it still is the most used keyboard application for Android devices, so this can be a big problem.
The workaround is to use either
android:inputType="textVisiblePassword"
or
.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
Try this if you want a multi-line EditText without displaying the underlines (auto correct):
myEditText.setInputType(InputType.TYPE_CLASS_TEXT |
InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
Here's XML for that: android:inputType="textNoSuggestions|textMultiLine".