Android Question Trying to resize a customlistview when the soft keyboard appears


Licensed User
I have a customlistview that I want to resize when the soft keyboard appears, and I swear it was working finally after a couple of nights of struggling, but all of the sudden it stopped working and for the life of me I cannot figure out why. It crashes when it gets to End Sub for IME1_HeightChanged

The stack I get is
java.lang.IllegalStateException: This method must only be called as part of a callback while a frame is in progress.
at android.view.Choreographer.getFrameTimeNanos(
at android.view.ThreadedRenderer.draw(
at android.view.ViewRootImpl.draw(
at android.view.ViewRootImpl.performDraw(
at android.view.ViewRootImpl.performTraversals(
at android.view.ViewRootImpl.doTraversal(
at android.view.ViewRootImpl$
at android.view.Choreographer$
at android.view.Choreographer.doCallbacks(
at android.view.Choreographer.doFrame(
at android.view.Choreographer$
at android.os.Handler.handleCallback(
at android.os.Handler.dispatchMessage(
at android.os.Looper.loop(
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(

and for code I have
Sub IME1_HeightChanged(NewHeight As Int, OldHeight As Int)
    Debugger("Entering IME_HeightChanged...")
    Dim intKeyboardSize As Int = Max(NewHeight, OldHeight) - Min(NewHeight, OldHeight)
    If NewHeight < OldHeight Then    ' Keyboard displayed
        'Debugger("CustomListView1.AsView.Tag:  " & CustomListView1.AsView.SetLayout(0, 0%y, 100%x, CustomListView1.AsView.Height - intKeyboardSize)
        CustomListView1.AsView.SetLayout(0, 0%y, 100%x, CustomListView1.AsView.Height - intKeyboardSize)
        'CustomListView2.AsView.SetLayout(0, CustomListView1.AsView.Height, 100%x, 10%y)
    Else                             ' Keyboard hidden
        CustomListView1.AsView.SetLayout(0, 0%y, 100%x, CustomListView1.AsView.Height + intKeyboardSize)
        'CustomListView2.AsView.SetLayout(0, CustomListView1.AsView.Height, 100%x, 10%y)
    End If
End Sub

CustomListView1 and CustomListView2 and IME1 are declared as global variables

    <more code>
Dim UIInput As String
Dim YHeightTotal As Int
Dim YHeight As Int
Dim ActivityHeight As Int
Dim CustomListView1Height As Int
YHeight = 50dip
ActivityHeight = Activity.Height
'Add the first panel with the list of options and an input field for each
Activity.AddView(CustomListView1.AsView, 0, 0%y, 100%x, ActivityHeight-YHeight)
For i = 0 To CustomListDBFields.Size - 1
    'Assign the edtbox/button type for the view
    UIInput = CustomListDBUIInput.Get(i)
    'Add the view now
        CustomListDBUnits.Get(i), CustomListView1.AsView.Width, _
        YHeight, UIInput, CustomListDBFields.Get(i), False), YHeight, CustomListDBFields.Get(i))

CustomListView2.Initialize(Me, "CustomListView2")
CustomListView1Height = CustomListView1.AsView.Height
HeightFromBottom = ActivityHeight - (ActivityHeight - CustomListView1Height)

Activity.AddView(CustomListView2.AsView, 0, HeightFromBottom, 100%x, YHeight)

'Add the second panel, with the buttons to control the dialog
CustomListView2.Add(CustomListView_CreateButtonItem(YHeight),YHeight,"not sure")

I am hoping someone has a quick pointer for me.



Licensed User
Thanks RandomCoder, I had already looked at that post.

Sheer luck just led me to discover the issue. If I place a breakpoint in the sub IME1_HeightChanged then it will crash, but if I take the breakpoint out everything works just fine. So I am all set now.
Upvote 0