Android Question CLV background click event

giggetto71

Active Member
Licensed User
Longtime User
Hi all,
I have a CLV which is filled dinamically during the usage of the app so there can be instances in which the clv is filled with only one or 2 items. For some reasons I would like to catch the event of someone clicking in the back ground in the below example in the circled area below the added items. i could not find any way.
any idea?
thanks!

 

LucaMs

Expert
Licensed User
Longtime User
Without modifying the source code of the CustomListView it will not be easy.

In B4A you could add an item composed only of a transparent Panel and manage the click of it. The difficulty will be in calculating the necessary height of this Panel and when to resize its height, based on the number of items.

Eventually, you can try to exploit some properties of the ScrollView that is the basis of the CustomListView:
B4X:
    CLV.sv.ScrollViewInnerPanel
    CLV.sv.ScrollViewContentHeight
    CLV.sv.ScrollViewOffsetY
 
Upvote 0

PaulMeuris

Active Member
Licensed User
And here's the test of what @LucaMs wrote:

After the CLV is filled you can adjust the panel (pane) below the scrollview content.
B4X:
Private Sub fill_clv1
    clv1.Clear
    Dim itemlst As List = get_textitems
    For i = 0 To itemlst.Size -1
        Dim item As String = itemlst.Get(i)
        clv1.AddTextItem(item,i)
    Next
    Pane1.PrefHeight = clv1.AsView.Height - clv1.sv.ScrollViewContentHeight
    Pane1.Top = clv1.sv.ScrollViewContentHeight + clv1.GetPanel(clv1.Size-1).Height + 5
End Sub
And then you can check if the pane has been clicked.
B4X:
Private Sub Pane1_MouseClicked (EventData As MouseEvent)
    Log("Pane1 clicked on: " & EventData.X  & " and " & EventData.Y)
End Sub

Make sure to set message #2 as the solution.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…