Android Question Click in view - CLVNested

Lucas Eduardo

Active Member
Licensed User
Hello, i am trying to make a layout that have three views in each item of CLV and it's a CLVNested.

I did an example project to demonstrate that it's not working. Is there a way to do this with CLVNested ?

this is not working
B4X:
Sub Label1_Click
    Dim index As Int = clvItem.GetItemFromView(Sender)
    Log("label1: "&index)
End Sub

Sub Label2_Click
    Dim index As Int = clvItem.GetItemFromView(Sender)
    Log("label2: "&index)
End Sub
 

Attachments

  • clickNested.zip
    13.8 KB · Views: 164

Lucas Eduardo

Active Member
Licensed User
Change CallSub2 to CallSub3 and add the X parameter to the event.
B4X:
CallSub3(ScrollingCLV, "Panel" & "ClickHandler", ScrollingCLV.GetRawListItem(innerIndex).Panel, X)

Thank you for your reply, i followed your suggest and i get this error
java.lang.Exception: Sub panelclickhandler signature does not match expected signature.

What could be?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
java.lang.Exception: Sub panelclickhandler signature does not match expected signature.
have you added the new parameter to panelclickhandler?
 
Upvote 0

Lucas Eduardo

Active Member
Licensed User
I don't think so, i don't undestand where add this new parameter to panelclickhandler. Can you show me?

i tryed this, but gave me the same error
B4X:
Sub CLVItem_ItemClick (Index As Int, Value As Object, test As Int)
    Log("test: "&test)
    Log("Value: "&Value)
    Log("Index: "&Index)
End Sub

Thank you.
 
Last edited:
Upvote 0

Lucas Eduardo

Active Member
Licensed User
You can instead store the offset in a global variable and get it inside the event sub.
I did it but i don't know how to get the correct view.
i tryed this but gave me an error.
B4X:
Dim lbl As Label = clvItem.GetPanel(Index).GetView(offset)
and
B4X:
Dim lbl As Label = clvItem.GetPanel(clvItem.FindIndexFromOffset(offset)).GetView(0)

Probably not the correct way to get the view, can you show me the correct way?

Thank you.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Assuming that your items layouts are not too complicated it should be quite simple. Something like:
B4X:
Dim pnl As B4XView = clvItem.GetPanel(Index)
For i = 0 To pnl.NumberOfViews - 1
Dim v As B4XView = pnl.GetView(i)
if v.Left <= offset And v.Left + v.Width >= offset Then
  Log("This view")
End If
 
Last edited:
Upvote 0
Top