Android Question Expandable list based on xCustomListView

Sergey_New

Well-Known Member
Licensed User
Longtime User
Is there an easy way to allow only one row to open and automatically close all other open rows?
 
Solution
solution finish:
B4X:
Sub clv1_ItemClick (index As Int, Value As Object)
    If Not(Currindex = index) Then
        Dim i As ExpandableItemData = clv1.GetValue(Currindex)
        If i.Expanded = True Then
            expandable.ToggleItem(Currindex)
        End If
    End If
    Sleep(300)
    expandable.ToggleItem(index)
    Currindex = index
End Sub

Mahares

Expert
Licensed User
Longtime User
Is there an easy way to allow only one row to open and automatically close all other open rows?
Do you mean for instance if the list has 5 items for a given panel, you want to show only the first one in the list and not show the other 4 when you expand the panel. . Can you explain better what you want.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
edit:
looks a little better
B4X:
Sub clv1_ItemClick (index As Int, Value As Object)
    If Not(Currindex = index) Then
        expandable.CollapseItem(Currindex)
        Currindex = index
    End If
    Sleep(300)
    expandable.ToggleItem(index)
End Sub
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
solution finish:
B4X:
Sub clv1_ItemClick (index As Int, Value As Object)
    If Not(Currindex = index) Then
        Dim i As ExpandableItemData = clv1.GetValue(Currindex)
        If i.Expanded = True Then
            expandable.ToggleItem(Currindex)
        End If
    End If
    Sleep(300)
    expandable.ToggleItem(index)
    Currindex = index
End Sub
 

Attachments

  • 1.zip
    5.4 KB · Views: 105
Upvote 1
Solution

TILogistic

Expert
Licensed User
Longtime User
Note:
You can set customlistview animation to match expandable effects.

Change:
B4X:
clv1.AnimationDuration = 200
CLVExpandable1.Initialize(clv1)

B4X:
Sub clv1_ItemClick (index As Int, Value As Object)
    If Not(Currindex = index) Then
        Dim i As ExpandableItemData = clv1.GetValue(Currindex)
        If i.Expanded = True Then
            CLVExpandable1.ToggleItem(Currindex)
        End If
    End If
    Sleep(clv1.AnimationDuration) 'Animation to match expandable effects
    CLVExpandable1.ToggleItem(index)
    Currindex = index
End Sub
 

Attachments

  • 1.zip
    5.6 KB · Views: 99
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
It's clear.
I'll ask one more question on the expandable list:
Is it possible to search through the headings of a long (about 10,000 rows) list and move to the found row when the data is not loaded all at once?
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
It's clear.

I am making some adjustments to the class.
Animations, icon fonts, expandable options (only one element, all elements) and other functionalities.
 

Attachments

  • 1.zip
    5.2 KB · Views: 108
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
Is it possible to search through the headings of a long (about 10,000 rows) list and move to the found row when the data is not loaded all at once?
yes

But it is another matter, I suggest you open a new post.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
I am making some adjustments to the class.
The last lines in the list are not fully visible when expanded. I would like to have automatic scrolling if substrings are not visible.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
The last lines in the list are not fully visible when expanded. I would like to have automatic scrolling if substrings are not visible.
see:
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
change:
B4X:
Public Sub ExpandItem (index As Int)
    Dim item As CLVItem = mCLV.GetRawListItem(index)
    Dim currentOffset As Int = mCLV.sv.ScrollViewOffsetY
    Dim id As ExpandableItemData = item.Value
    Dim itemBottom As Int = item.Offset + id.ExpandedHeight
    ResizeItem(index, False)
    Dim delta As Int = itemBottom - currentOffset - mCLV.AsView.Height
    If delta > 0 Then
        Sleep(5)
        Dim offset As Int = itemBottom - mCLV.AsView.Height
        #if B4i
        Dim nsv As ScrollView = mCLV.sv
        nsv.ScrollTo(0, offset, True)
        #else if B4J
        Sleep(50)
        mCLV.sv.ScrollViewOffsetY = offset
        #Else If B4A
            Dim nsv As ScrollView = mCLV.sv
            nsv.ScrollPosition = offset
        #End If
    End If
End Sub
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I've only read the title (bad thing, I shouldn't have done it) and I know that what I'm about to write will be criticized by many, also for this reason.

Reading it I immediately thought:
it is wrong to perform a search in a View, of whatever type it is.

I think it is more correct that a processing, such as a search, should be carried out on a data structure associated with a View.
This is because keeping data and UI separate is a good general rule, for various reasons.

I am not writing more, so as not to receive too many insults ?
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
 

Attachments

  • B4J_ExpandableList.zip
    6.1 KB · Views: 97
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
I have seen your code and I recommend you to see @Peter Simpson customlistview tutorials, he has several very good examples that will help you to know and understand better.
@Peter Simpson
see examples of search in clv
etc. etc.

and @Erel
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…