Android Question [B4X] CLVSwipe - xCustomListView PullToRefresh Breaks KEyBoard Adjustment

MrKim

Well-Known Member
Licensed User
Longtime User
If you modify the CLVSwipe example to use EditTexts the EditText views will not be pushed up to remain visible when the Keyboard is opened. I have included an example program.

Remming the following 4 lines will make it work correctly but you will no longer have the pull to refresh feature.
B4X:
    Dim PullToRefreshPanel As B4XView = xui.CreatePanel("")
    PullToRefreshPanel.SetLayoutAnimated(0, 0, 0, 100%x, 70dip)
    PullToRefreshPanel.LoadLayout("PullToRefresh")
    Swipe.PullToRefreshPanel = PullToRefreshPanel

You can do it manually using IME. The following code works for me. It will need to be modified to suit your purposes.

B4X:
Sub Globals
    Dim CTxt As EditText
.
.
.
End Sub

Sub AddTxtItem
  Dim Pnl As B4XView = xui.CreatePanel("")
  Dim Txt As EditText
  Txt.Initialize("Txt")
.
.
.
.
Pnl.AddView(Txt, 0, 0, 100%x, 48dip)
ActiveList.Add(Pnl, ActiveSwipe.CreateItemValue("", Array(trash, Arch)))
.
.
.

End Sub


Sub Txt_FocusChanged (HasFocus As Boolean)
    Dim SS As NotePoperties
Try
    If Sender <> Null Then
        CTxt = Sender
        SS = CTxt.Tag
        If HasFocus Then
            CTxt.Color = CP.COLORtoHSL(SS.BClr)
        Else
            CTxt.Color = SS.BClr
        End If
    End If
Catch
    ToastMessageShow("Txt_FocusChanged" & CRLF & LastException.Message, True)
End Try

End Sub


Sub IME_HeightChanged (NewHeight As Int, OldHeight As Int)
    Dim X As Long, Ht As Long
    
    Try
        If NewHeight < OldHeight Then
            For X = ActiveList.LastVisibleIndex To (Max(ActiveList.GetItemFromView(CTxt) + 1, 0)) Step -1
                Ht = Ht + ActiveList.GetPanel(X).Height
            Next
            If (NewHeight + Ht) < OldHeight Then
                ActiveList.AsView.Parent.Parent.Top = ActiveList.AsView.Parent.Parent.Top - ((OldHeight - (NewHeight + Ht)))
            End If
        Else
            ActiveList.AsView.Parent.Parent.Top = (NewVoiceBtn.Height + NewVoiceBtn.Top)
            'ActiveList.AsView.Top = 0
        End If
        KbdVisible = (NewHeight < OldHeight)
    
    Catch
        ToastMessageShow("IME_HeightChanged" & CRLF & LastException.Message, True)
    End Try
    
End Sub
 

Attachments

  • SwipeTest.zip
    17.8 KB · Views: 361
Top