Android Question Nested CLV inside Expanded CLV

jahswant

Well-Known Member
Licensed User
Longtime User
I followed Erel's instructions here about how to make this work.


B4X:
Private Sub GetInnerCLVFromTouch (x As Float, Y As Float) As CustomListView
    Dim index As Int = CLV.FindIndexFromOffset(Y + CLV.sv.ScrollViewOffsetY)
    Dim item As CLVItem = CLV.GetRawListItem(index)
    Dim ep As ExpandableItemData = item.Value '<---- new code in CLVNested
    If ep.Expanded = False Then
        Return Null
    End If
    If item.Panel.GetView(0).Tag Is CustomListView Then
        Dim inner As CustomListView = item.Panel.GetView(0).Tag
           
        If inner.AsView.Left <= x And inner.AsView.Left + inner.AsView.Width >= x Then Return inner
    End If
    Return Null
End Sub

it seems like the Click Event is ignored when Expaned.

I can expand the CLV but collapsing is not working at all. Has someone finally combined Expandable with Nested ?

MY UI look like this."This is a b4j snapshot". After expanding there's no way back.

1716429002963.png
 
Last edited:
Solution
Here's a small example of a CustomListView where the items can be expanded or collapsed using Erel's CLVExpandable class.
The main CLV contains 10 items. Each item is expandable or collapsible.
The expanded panel contains an inner CLV with a variable item count. Next to the inner CLV is a B4XSeekBar.
The scrolling of the inner CLV is done with the B4XSeekBar by tapping on it at a certain distance from the bottom.
I didn't find a good solution (yet) to do the scrolling of the inner CLV. There is a conflict with the main CLV over the touch actions.
Maybe you find it a real challenge and find a solution? Until then the B4XSeekBar does a fairly good scrolling job.
1716541549258.png
1716541629360.png
1716541696905.png
1716541773178.png

1716541931721.png

You can...

MicroDrie

Well-Known Member
Licensed User
Longtime User
I can expand the CLV but collapsing is not working at all. Has someone finally combined Expandable with Nested ?
The answer is yes, but I managed it years ago in both B4A and B4J. I think the problem is probably that your expandable list is not on top of the underlying scroll list. Without a small example project it is impossible to say what should be done differently.
 
Upvote 0

PaulMeuris

Active Member
Licensed User
Here's a small example of a CustomListView where the items can be expanded or collapsed using Erel's CLVExpandable class.
The main CLV contains 10 items. Each item is expandable or collapsible.
The expanded panel contains an inner CLV with a variable item count. Next to the inner CLV is a B4XSeekBar.
The scrolling of the inner CLV is done with the B4XSeekBar by tapping on it at a certain distance from the bottom.
I didn't find a good solution (yet) to do the scrolling of the inner CLV. There is a conflict with the main CLV over the touch actions.
Maybe you find it a real challenge and find a solution? Until then the B4XSeekBar does a fairly good scrolling job.
1716541549258.png
1716541629360.png
1716541696905.png
1716541773178.png

1716541931721.png

You can tap on items from each inner CLV to select them. Check the logs panel for the list of selected items.
I didn't create a B4J version yet.
You can find the B4A source code in the attachment (testenvironment44.zip).
The app was tested with an Android 8.1.0 device and an Android 14 device with One UI 6.0
I removed the starter module from the project to fix the blank screen at startup.
 

Attachments

  • testenvironment44.zip
    13.2 KB · Views: 111
Upvote 0
Solution
Top