Android Question How to refer to CustomView inside a CLV

epiCode

Active Member
Licensed User
I have a customview inside clv which I want to change property of.

I tried following method without any success:
Note:
Target panels have "Target" in tag​
Highlight is name of custom view which has a .text property too​
Panels can have multiple items including or excluding highlight​

B4X:
For Each pnl As Panel In CLVMain.GetBase.GetAllViewsRecursive
        If pnl.Tag = "Target" Then
            For Each hi As Highlight In pnl.GetAllViewsRecursive
                hi.text = "Changed"
            Next
        End If
    Next
it fails on line with hi.text with following error
java.lang.RuntimeException: Field: ba not found in: anywheresoftware.b4a.BALayout

Can someone help on what am I doing wrong?
Thanks!
 

Alexander Stolte

Expert
Licensed User
Longtime User
For Each pnl As Panel In CLVMain.GetBase.GetAllViewsRecursive If pnl.Tag = "Target" Then For Each hi As Highlight In pnl.GetAllViewsRecursive hi.text = "Changed" Next End If Next
B4X:
For Each pnl As Object In CLVMain.GetBase.GetAllViewsRecursive
     If pnl.Tag = "Target" Then
         For Each hi As Object In pnl.GetAllViewsRecursive
         if hi is Highlight then
              hi.As(Highlight).text = "Changed"
              end if
         Next
     End If
Next
Check first if your "Highlight" is really the datatype "Highlight".
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
I think, Erel means this,

B4X:
As these conventions are rather new, they are not used by some popular custom views such as xCLV. You can set the base panel tag yourself in such cases. For example:
B4X:
Activity.LoadLayout("1")
clv.AsView.Tag = clv
'now we can get the clv with:
Dim c As CustomListView = Activity.GetView(<clv index>).Tag
 
Upvote 0
Top