B4J Question Changing a CLV Item Layout

GuyBooth

Active Member
Licensed User
Longtime User
I have a CLV where I want to change the label layout after the layout file has been loaded into the item.
The simple way of achieving this doesn't work - I'm sure there's a good reason.
B4X:
ub Add_DetailedCLVItem(pnlItemBase As B4XView, uItem As udtItem)
'    If pnlItemBase.NumberOfViews = 0 Then
        pnlItemBase.LoadLayout("ItemDetails")
        lbl1.Text = uItem.text
        lbl2.Text = $"Information on the ${lbl2LorR}"$
        lbl3.text = $"Data on the ${lbl3LorR}"$
        lbl2.SetLayoutAnimated(0, lbl2Position,0,150,30)
        lbl3.SetLayoutAnimated(0, lbl3Position,0,150,30)
'  lbl3.RemoveViewFromParent
'    End If
End Sub
The setlayoutanimated methods have no effect, although interestingly the RemoveViewFromParent works when uncommented.
I'm attaching a project with the complete code
Screenshot Left shows how it looks on startup and should look after clicking the "Move Left" button
Screenshot Right show how it looks after clicking the "Move Right" button - but the label that says "Information on the Right" should BE on the right, and the label that says "Data on the Left" should BE on the left.

Help would be appreciated ...
 

Attachments

  • MoveCLVTxf.zip
    4.3 KB · Views: 138
  • Screenshot Left.png
    Screenshot Left.png
    94.4 KB · Views: 163
  • Screenshot Right.png
    Screenshot Right.png
    97 KB · Views: 148

GuyBooth

Active Member
Licensed User
Longtime User
Better to do it in the layout file directly. With anchors or designer script.
This can't be done until the detail to be entered into each item is known, so I don't see that presetting it in the layout file is an option.
I am able to set the total item height when I add the item, and I am doing that.
If you insist on doing it in the code then uncheck the "handle resize event" in the layout properties.
This seems to have the desired effect, will explore further.
 
Upvote 0
Top