Android Question customlistview jumptoitem & IME HeightChanged keyboard event issue

leitor79

Active Member
Licensed User
Longtime User
Hi,

I have a customlistview on my activity (among others), and I'm handling the keyboard opening and closing events to manage the views sizes to fit the new screen size. That works ok.

However, I want to use the jumptoitem method to show the last item of the customlistview when I open or close the keyboard. So, I've added this line at the end of the event:

B4X:
lstChat.JumpToItem(lstChat.GetSize)

This works OK when I close the keyboard, but when I open it, the customlistview "moves" to show items below, but it not show the last one.

B4X:
Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int)
pnlTop.Left=0
pnlTop.Top=0
pnlTop.Width=100%x
pnlTop.Height=50dip

pnlBottom.Left=0
pnlBottom.Width=100%x
pnlBottom.Height=50dip
pnlBottom.Top=NewHeight - pnlBottom.Height

Dim v As View
v=lstChat.asview
v.Top=pnlTop.Height
v.Left=0
v.Width=100%x
v.Height=NewHeight-pnlTop.Height -pnlBottom.Height

lstChat.JumpToItem(lstChat.GetSize)

End Sub


Thanks!
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

leitor79

Active Member
Licensed User
Longtime User
Thanks Erel, the CallSubDelayed option worked it out. The first one gived me an error; I suppose I didn't used it right (I'm not familiar with the javaobects component):

B4X:
Dim jo As JavaObject = lstchat
jo.RunMethod("requestLayout", Null)

Since the CallSubDelayed method works, I don't need this, but I'm posting it for future reference...
 
Upvote 0
Top