Android Question [SOLVED] How to show keyboard with allcaps and (!) no predictions

adrianstanescu85

Active Member
Licensed User
Longtime User
Hello

1. I tried to set up the soft keyboard to show ALLCAPS and disable the predictions, so that the user inputs easily capital letters from the start as shown on the keyboard, and when the user clicks Done/Next, the text entered would not change according to predictions. Also, the keyboard shown needs to overlap the user screen, not substitute it as the user enters the text.

In order to do so, I am using the following code:
B4X:
EditID.InputType = Bit.Or(EditID.INPUT_TYPE_TEXT, 4096)
Ref3.Target = EditID ' The text field being referenced
Ref3.RunMethod2("setImeOptions", 268435456, "java.lang.int")
but this only fixes capital letters (and good overlap over the activity), it does not disable the predictions at the same time.

Any suggestions on how to do it?

---------------------------------------

2. Also, the EditText that will contain the text is being set as ready to use for the user when clicking a button. I used the RequestFocus to do so, and this puts the prompt inside the EditText, but it does NOT automatically bring up the soft keyboard.

Any idea on how to do that automatically?


Many thanks!
Adrian
 

adrianstanescu85

Active Member
Licensed User
Longtime User
Thank you for the replies.

I tried EditID.InputType = 128 and this did hide the suggestions (as well as = 144). The .InputType = Bit.Or(EditID.INPUT_TYPE_TEXT, 524288) was tried before with no effect at all.

However, even if the above method hides the suggestions, it does not set the keyboard to type from the start with All caps. Any ideas on how to do so?

Thank you!
Adrian
 
Upvote 0

adrianstanescu85

Active Member
Licensed User
Longtime User
It does set the keyboard with all caps, that works.

However, I cannot seem to obtain all caps AND hide predictions at the same time (I can do either but not both)...
 
Upvote 0

adrianstanescu85

Active Member
Licensed User
Longtime User
Yes, here is the code. EditID is placed under LabelPressID, so when LabelPressID is long pressed it gets out of the way of EditID and should show the keyboard on screen (overlapping the current screen content, not full screen) with all caps and no predictions at the same time. The point is to be able to enter a numeric code written on a wristband just as it is.

B4X:
Sub LabelPressID_LongClick
    Label49.Visible = False
    EditID.Enabled = True
    EditID.Visible = True
    LabelPressID.Visible = False
    'EditID.RequestFocus
    Dim IME2 As IME
    IME2.Initialize("")
    IME2.SetCustomFilter(EditID, 0x00001000, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
    'Ref3.Target = EditID
    'Ref3.RunMethod2("setImeOptions", 268435456, "java.lang.int")
    'EditID.InputType = Bit.Or(EditText1.InputType, 0x00001000)
    'IME2.ShowKeyboard(EditID)
End Sub

Thank you!
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
on 3 devices 2.3.6 - 4.1.2 - 5.02 this single line worked to turn ON Capitals and suppress suggestions / predictive text
B4X:
EditID.InputType = Bit.Or(144, 0x00001000)
 
Upvote 0

adrianstanescu85

Active Member
Licensed User
Longtime User
Thank you for suggesting
B4X:
EditID.InputType = Bit.Or(144, 0x00001000)
but unfortunately it does not work on my side. I tried it on several devices too.

Do I need to do any changes or specifications in the Manifest?

Thank you
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User

Attachments

  • EditText Test.zip
    7.6 KB · Views: 193
Upvote 0

adrianstanescu85

Active Member
Licensed User
Longtime User
You can also try Masked EditText with the following properties:
InputType = met.INPUT_TYPE_TEXT_WITH_CAPS
WithSuggestions = False

This is the only approach that works, however with one tiny fault: it only sets the First letter of the text as caps. Any idea on how to set the keyboard to full caps when using the Masked EditText?

I do have to mention I am using the SwiftKey keyboard, but I tried the app on some other devices that come with a stock keyboard and the issues are the same.
 
Upvote 0

adrianstanescu85

Active Member
Licensed User
Longtime User
I already did that, and it can also be done with any keyboard setting, even one that shows only lower case characters. The point is to have the keyboard set from the start, I am sure it can be done since we already have the option of upper casing the first letter for the moment. Since that is in fact an int type setting, I was wondering if there is one that would match the all caps for the Masked EditText.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
I already did that, and it can also be done with any keyboard setting, even one that shows only lower case characters. The point is to have the keyboard set from the start, I am sure it can be done since we already have the option of upper casing the first letter for the moment. Since that is in fact an int type setting, I was wondering if there is one that would match the all caps for the Masked EditText.
Set InputType to 4096.
 
Upvote 0

adrianstanescu85

Active Member
Licensed User
Longtime User
Indeed this solves the problem!

Maybe it's also important mentioning for other users who might need this in the future that installing and using different types of keyboard apps may influence the outcomes. When using the Masked Edittext approach, even with the InputType set to 4096 which stands for full capitalization, the keyboard is shown in lowercase letters. However, on other stock keyboards, it shows fine with all caps on. This wasn't possible in my experience to be done with the EditText control, so getting the Masked Edittext helped a lot!

Thank you!
 
Upvote 0
Top