B4J Question B4X CLV nested CLV. Get Record and Index

MarcoRome

Expert
Licensed User
Longtime User
Hi everyone.
I have a CLV inside a CLV.
The first repeats a cycle for n times where it goes to insert a clv that scrolls horizontally.
I would need to color the label I select in the right record.
Example:
1. If I click on "Interno6", instead of coloring "Interno6" it colors the last record.
Any operation i perform is repeated only on the last record added.


1653103052187.png


2. It would be necessary to color the right label that I select and if I have previously selected a label it must lose its color.
Basically i can select only one label at a time.
So, for example, if i select the "Interno6" label it will turn green, if i click on "Interno7" the "Interno6" label loses its color and the "Interno7" label is colored.

Any idea ?
Thank you all.
Marco

In attachment example.
 

Attachments

  • clvinsideclv.zip
    5 KB · Views: 103

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
I commented clv_interna_ItemClick sub & uncommented last sub Private Sub lbl_inside_clv_MouseClicked and add single code of color:
B4X:
Sub clv_interna_ItemClick (Index As Int, Value As Object)
    Log($"Da ItemClick CLV Record:${Index} Valore${Value)}"$
'    Dim pnl As B4XView
'    pnl = clv.GetPanel(Index)
'    Dim coloro_lbl As B4XView
'    coloro_lbl = pnl.GetView(0)  'Label
'    Log(coloro_lbl.Text)
'    coloro_lbl.Color = xui.Color_Green

    
'    Dim pnl As B4XView
'    pnl = clv_interna.GetPanel(Index)
'    Dim coloro_lbl As B4XView
'    coloro_lbl = pnl.GetView(0)  'Label
'    Log(coloro_lbl.Text)
'    coloro_lbl.Color = xui.Color_Green
    

    
End Sub


Private Sub lbl_inside_clv_MouseClicked (EventData As MouseEvent)
    Dim b As B4XView
    b = Sender
    b.Color = xui.Color_Green
    Log($"Da Label Valore${b.Tag)}"$
End Sub

Worked fine.
 
Upvote 1

MarcoRome

Expert
Licensed User
Longtime User
I commented clv_interna_ItemClick sub & uncommented last sub Private Sub lbl_inside_clv_MouseClicked and add single code of color:
B4X:
Sub clv_interna_ItemClick (Index As Int, Value As Object)
    Log($"Da ItemClick CLV Record:${Index} Valore${Value)}"$
'    Dim pnl As B4XView
'    pnl = clv.GetPanel(Index)
'    Dim coloro_lbl As B4XView
'    coloro_lbl = pnl.GetView(0)  'Label
'    Log(coloro_lbl.Text)
'    coloro_lbl.Color = xui.Color_Green

   
'    Dim pnl As B4XView
'    pnl = clv_interna.GetPanel(Index)
'    Dim coloro_lbl As B4XView
'    coloro_lbl = pnl.GetView(0)  'Label
'    Log(coloro_lbl.Text)
'    coloro_lbl.Color = xui.Color_Green
   

   
End Sub


Private Sub lbl_inside_clv_MouseClicked (EventData As MouseEvent)
    Dim b As B4XView
    b = Sender
    b.Color = xui.Color_Green
    Log($"Da Label Valore${b.Tag)}"$
End Sub

Worked fine.
Yep, it was that simple.
I need a vacation.
Thanks you @Hamied Abou Hulaikah for opening my eyes.
 
Upvote 0
Top