Android Question CustomListView and sv.ScrollViewInnerPanel [Solved]

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All

I am trying to ensure the ScrollViewInnerPanel aligns with scrollview in CLV.
I don't even know if aligning is possible/needed I am just speculating that this may the cause of a small problem. It looks simple enough.

I have tried the code below but it throws the error shown.

B4X:
    CLV.GetBase.Height = 100%y - LBLTitle.Height      'Set height of CLV
    CLV.GetBase.Top = LBLTitle.Height                         'Set position of CLV on Activity/Panel

    CLV.sv.Height =CLV.GetBase.Height                      'Set sv to same height as CLV
    CLV.sv.Top = CLV.getbase.Top                               'Align top of sv with top of CLV

    CLV.sv.ScrollViewInnerPanel.Top = CLV.sv.Top       'Should align top of ScrollViewInnerPanel with top of sv but crashes

The last line of the code above causes the error shown below.

No wakelock.
main_settingsmenu (java line: 17238)
java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to anywheresoftware.b4a.BALayout$LayoutParams
at anywheresoftware.b4a.objects.ViewWrapper.setTop(ViewWrapper.java:188)
at anywheresoftware.b4a.objects.B4XViewWrapper.setTop(B4XViewWrapper.java:126)
at b4a.C_Calc.main._settingsmenu(main.java:17238)
at b4a.C_Calc.main._alllistview_itemclick(main.java:3613)

Q1. Is it possible to align sv with ScrollViewInnerPanel? If not I will try something else.
Q2. What am I doing wrong?

Regards Roger
 

Roger Daley

Well-Known Member
Licensed User
Longtime User
What exactly do you want to achieve, align?
Why do you want to set ScrollViewInnerPanel.Top?

Klaus,

I had an issue where a CLV was showing a list with an overly large space between the Title Label and the first item.
I was clutching at straws with the speculation that this could be caused by the ScrollViewInnerPanel sitting low in the sv. [Wrong]

I have fixed that problem with the change in code below. Comment out the lines that should align the sv with the CLV and the problem is gone.

B4X:
    AllListView.GetBase.Height = 100%y - AllListTitle.Height
    AllListView.GetBase.Top = AllListTitle.Height
   
'    AllListView.sv.Height = AllListView.GetBase.Height                           ''With these two lines removed all OK
'    AllListView.sv.Top = AllListView.getbase.Top

I am still chasing an issue that only 5 of the items are displayed although there is screen space and the CLV dimensioned to use it.
I can't recreate the issue in a small project for upload.
That is a separate problem for a new thread if I can recreate the problem in a sample project.

Regards Roger

PS Change the two lines in question fixes it all round.
B4X:
AllListView.sv.Height = AllListView.GetBase.Height
AllListView.sv.Top = 0
 
Last edited:
Upvote 0
Top