Android Question Nested CLV in a grid Like DATASET.

jahswant

Well-Known Member
Licensed User
Longtime User
I'm using https://www.b4x.com/android/forum/threads/clvnested-allows-nesting-clvs.107742/#content to try interact with nested clv. But my nested item contains multiple CLV(04) in a grid form. I use this code below to set the tags. I'm I missing something ? Because Only the last CLV interacts with the scroll and i have to scroll on the first gris Item.

B4X:
    Dim CurrentCustomListViewNested As CLVNested
   
    pnlContent.LoadLayout("kitchenbase")

    CurrentCustomListViewNestedExpanded.Initialize(BasePanelSingle)
    CurrentCustomListViewNestedExpanded.base.LoadLayout("kitchencard")
    CurrentCustomListViewNestedExpanded.CLV = CustomListViewKitchenSignle


B4X:
Private Sub CustomListViewKitchen_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
    Try

        For Each i As Int In PCLV.VisibleRangeChanged(FirstIndex, LastIndex) 'Loop through the PCLV
            Dim Row As CLVItem = CustomListViewKitchen.GetRawListItem(i) 'Get row x
            Dim Pnl As B4XView = xui.CreatePanel("")
            Row.Panel.AddView(Pnl, 0, 0, CustomListViewKitchen.AsView.Width, Row.Panel.Height)
            Pnl.LoadLayout("griditemkitchen")

            Dim OrderVal As List = Row.Value
           
            For k = 0 To OrderVal.Size -1
               
                Dim CurrentCustomListView As CustomListView
                Dim OrderValues As String = OrderVal.Get(k)
                Select k
                    Case 0
                        CustomListView1.AsView.Tag = CustomListView1
                        CurrentCustomListView = CustomListView1.AsView.Tag
                        Pnl.Tag = CustomListView1
                    Case 1
                        CustomListView2.AsView.Tag = CustomListView2
                        CurrentCustomListView = CustomListView2.AsView.Tag
                        Pnl.Tag = CustomListView2
                    Case 2
                        CustomListView3.AsView.Tag = CustomListView3
                        CurrentCustomListView = CustomListView3.AsView.Tag
                        Pnl.Tag = CustomListView3
                    Case 3
                        CustomListView4.AsView.Tag = CustomListView4
                        CurrentCustomListView = CustomListView4.AsView.Tag
                        Pnl.Tag = CustomListView4
                End Select
               
                Dim LabelOrderNumber,LabelOrderTime,LabelOrderIconType,LabelOrderIconEnlarge,ButtonAction As B4XView
                LabelOrderNumber = Pnl.GetView(0).GetView(k).GetView(1)
                LabelOrderTime = Pnl.GetView(0).GetView(k).GetView(2)
                LabelOrderIconType = Pnl.GetView(0).GetView(k).GetView(3)
                LabelOrderIconEnlarge = Pnl.GetView(0).GetView(k).GetView(4)
                ButtonAction = Pnl.GetView(0).GetView(k).GetView(5)
                LabelOrderIconEnlarge.Tag = OrderValues
                Dim parser As JSONParser
                parser.Initialize(OrderValues)
                Dim jRoot As Map = parser.NextObject
                Dim order_id As Int = jRoot.Get("order_id")
                Dim placed_date_time As String = jRoot.Get("placed_date_time")
                LabelOrderNumber.Text = order_id
                LabelOrderTime.Text = placed_date_time
                LabelOrderIconType.Text = Chr(0xF290)
                LabelOrderIconEnlarge.Text = Chr(0xF065)
                Dim order_details As List = jRoot.Get("order_details")
                For Each colorder_details As Map In order_details
                                       
                    Dim PnlItem As B4XView = xui.CreatePanel("")
                    PnlItem.SetLayoutAnimated(0,0,0,CurrentCustomListView.AsView.Width,CurrentCustomListView.AsView.Height/4)
                    PnlItem.LoadLayout("kitchengridcount")
                    PnlItem.Tag = CurrentCustomListView 'must set the Panel tag like this
                    PnlItem.GetView(0).GetView(1).Text = colorder_details.Get("miname")
                    PnlItem.GetView(0).GetView(0).Text = FormatQtyNumber(colorder_details.Get("item_qty"))
                   
                    #If B4J
                    PnlItem.GetView(0).GetView(0).As(Label).WrapText = True
                    PnlItem.GetView(0).GetView(0).As(JavaObject).RunMethod("setTextAlignment", Array("CENTER"))
                   
                    PnlItem.GetView(0).GetView(1).As(Label).WrapText = True
                    PnlItem.GetView(0).GetView(1).As(JavaObject).RunMethod("setTextAlignment", Array("CENTER"))
                    #End If

                    CurrentCustomListView.Add(PnlItem,colorder_details.Get("item_number"))
                Next
               
                ButtonAction.Text = Main.Loc.Localize("get_started")
                Pnl.GetView(0).GetView(k).Visible = True
            Next
        Next
    Catch
        Log(LastException)
    End Try
End Sub

1716428908086.png
 
Last edited:
Top