Android Question EditText on Mobile device

nibbo

Active Member
Licensed User
Longtime User
Screenshot_20161108-154002.png
I am adapting my app which normally runs on a tablet to run on a mobile.

When I click on an Edittext control however it behaves very differently to a tablet.
The screen is effectively blank with just a 'DONE' button and the keyboard showing as per the above image.
I can type text and click done and it then goes back to normal but the user experience is little naff as I do search for things in a database after each keystroke.

Is this normal behaviour for a phone app?

Thanks
 

nibbo

Active Member
Licensed User
Longtime User
And what is the difference? If you search a db after each keystroke I think you have the search code in the EditText changed event (or, better, you call a function from this event), or not?
The Edittext is used so the user can search for customers and I return results each time the text changes.
When the screen is shown as in my first post the layout is not visible so the search results cannot be seen.
It is usable just not a great experience for the user.
Am about to try Erel's suggestion above which no doubt will work.
Thanks
 
Upvote 0

nibbo

Active Member
Licensed User
Longtime User
Yes. This is the default behavior. You can prevent it if you like: https://www.b4x.com/android/forum/t...with-the-ime-library.14832/page-6#post-222850
Thanks Erel this works a treat.
I wrote up a quick public function that can be called from any activity to apply this to all Edittext fields in the layout if anyone finds it useful.

B4X:
Public Sub SetIMEOptionsForEditTexts(activity As Activity)
    Dim JO As JavaObject
    For Each v As View In activity.GetAllViewsRecursive
        If v Is EditText Then
            Try
                JO = v
                JO.RunMethod("setImeOptions", Array As Object(268435456)) 'IME_FLAG_NO_EXTRACT_UI
            Catch
                Log(LastException)
            End Try
        End If
    Next
End Sub
 
Upvote 0
Top