Android Question Enable/Disable SoftKeyboard

JimAvanti

Member
Licensed User
Longtime User
I have a program that uses a Bluetooth barcode scanner (Which installs as a keyboard) to scan serial numbers and display the record for that serial number. There are other Textboxes that you can click on to change fields of the displayed record. The problem I am having is I need the softkeyboard to display if I click on one of the editable text boxes. With the barcode scanner turned on the soft keyboard never displays. Is there a way I can Display the softkeyboard if certain textboxes have focus and not display it if the textbox I use for the scanner has focus?


Thanks,

Jim
 

klaus

Expert
Licensed User
Longtime User
... have focus and not display it if the textbox I use for the scanner has focus?
Do you really need an EditText for displaying the value of the scanner, couldn't you use a Label for that instead of an EditText?
 
Upvote 0

JimAvanti

Member
Licensed User
Longtime User
I am using an EditText which is actually "off-screen" to capture (On EnterPressed) the serial number of an item. I then search through the database and if that serial number is found it will display the item, but it also gives the option to change some of the data (such as location and status of the item). Those fields require a software keyboard. When idle, I set focus back to the EditText that the scanner uses so it is ready to read another serial number.

The program did work the way I wanted it to but I had the problem of the program restarting and clearing the database changes every time the Bluetooth scanner would turn on/off which I was able to fix by adding the line:
SetActivityAttribute(Main, android:configChanges,"keyboard|keyboardHidden|navigation") to the Manifest. After editing the manifest, the scanner turning on/off did not affect the program restarting, but ever since then when I click on a text field to edit, the softkeyboard does not show up. Fixing one step at a time...

Jim

Do you really need an EditText for displaying the value of the scanner, couldn't you use a Label for that instead of an EditText?
 
Upvote 0

JimAvanti

Member
Licensed User
Longtime User
I think I might have fixed the problem using IME, but like an idiot I took the Bluetooth keyboard home to test it and forgot to bring it back to work. I did get some IME code to compile though.

I added the Global
B4X:
Dim IME1 As IME

I added this Sub for the EditText I want to show the keyboard:
B4X:
Sub StatusText_FocusChanged (HasFocus As Boolean)
    If HasFocus = True Then
        IME1.ShowKeyboard(StatusText)
    End If
End Sub

And this for the Scanner that I don't want the keyboard to show:
B4X:
Sub Text1_FocusChanged (HasFocus As Boolean)
    If HasFocus = True Then
        IME1.HideKeyboard()
    End If
End Sub

I have hope that it will work. At least I know it runs.

Thanks,
Jim

 
Upvote 0

JimAvanti

Member
Licensed User
Longtime User
MJ,

I did try the IME Library, but it still didn't show the softkeyboard. I think I may be needing to switch the Scanner to serial mode if it supports that. You would think it would be easy to select between software keyboard and hardware keyboard, especially since there are many keyboard devices that are not actually keyboards.

If you get a chance, check my replies to see how I used IME to make sure I was doing it correctly.

Thanks,
Jim


I did look quick at that library when searching for answers, but it didn't look like it would work for me. I guess I need to give it another look tomorrow...

Thanks,

Jim
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
At a quick glance the code looks OK and should have worked .

Did you try @KMatle 's example suggested post#6. ??

Other than that, maybe you could upload a small sample project highlighting your issue ... Menu > File > Export as Zip
Maybe someone who has / uses a scanner can then help.
 
Upvote 0
Top