Android Question xcustomlistview show an object near clicked item

Addo

Well-Known Member
Licensed User
i have two xcustomlistview in my project first clv called CustomListView1 and i use it as chat box
second clv called copymenu and i use it as menu

i am trying to place copymenu at the position of the clicked item of CustomListView1 in a previous thread Erel Suggested to do the following

B4X:
Sub CustomListView1_ItemClick (Index As Int, Value As Object)
    copymenu.AsView.Top = CustomListView1.GetPanel(Index).Top - CustomListView1.sv.ScrollViewOffsetY + CustomListView1.GetBase.Top
    If copymenu.AsView.Visible = True Then
        copymenu.AsView.Visible = False

    else If copymenu.AsView.Visible = False Then

        copymenu.AsView.Visible = True

    End If
End Sub

but the copy menu position is always showing on top not near the clicked item as it should be

what could be my mistake ?
 

Addo

Well-Known Member
Licensed User
i have logged copymenu Top property each time item clicked it return Zero

the clicked items list i added like that

B4X:
Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
   
    Dim p As Panel
    p.Initialize("")
    p.SetLayout(0, 0, Width, Height)
    p.LoadLayout("cellitem")
    lbltextbox.Text = Text
    lbltextbox.Height = Height
    lbltextbox.TextColor = 0xff000000
    Return p
End Sub
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I had a deeper look at your problem.

It seems that is a problem with the GetPanel method in the xCustomListView.
The original routine is:
B4X:
Public Sub GetPanel(Index As Int) As B4XView
    Return GetItem(Index).Panel.GetView(0)
End Sub
With the routine above, CustomListView1.GetPanel(Index).Top always returns 0.

With this routine it works.
B4X:
Public Sub GetPanel(Index As Int) As B4XView
'    Return GetItem(Index).Panel.GetView(0)
    Return GetItem(Index).Panel
End Sub
With the routine above, CustomListView1.GetPanel(Index).Top always returns the correct value.

It seems that there are two Panels for each CustomListView item.
 
Upvote 0

Addo

Well-Known Member
Licensed User
this raise exception if you will use this list in other purpose as example changing something in certain item

B4X:
Public Sub updateanitem
Dim p As B4XView = clvlist.GetPanel(0)
p.GetView(0).Text = "something new "
      
End Sub

notice that in my none test app
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I know that is a problem and I think that Erel needs to look at this.
To get the Top property we need: Return GetItem(Index).Panel
For the other properties we need: Return GetItem(Index).Panel.GetView(0)
It seems that there are two panels or B4XViews superimposed.
The first one holds the position, the dimesions are the same, and the second, a child of the first, holds the underlying views.
 
Upvote 0
Top