Android Question xCustomListView isn't supported XUI View

Theera

Well-Known Member
Licensed User
Longtime User
I have tried use SwiftButton in XUI View instead of Button View.
I use this
Dim xClVIndex as Int=ClVList.GetItemFromView(Sender)

I have the problem. I think GetItemFromView() cann't detect.
 

Attachments

  • shopping.zip
    120.3 KB · Views: 67

LucaMs

Expert
Licensed User
Longtime User
I have tried use SwiftButton in XUI View instead of Button View.
I use this
Dim xClVIndex as Int=ClVList.GetItemFromView(Sender)

I have the problem. I think GetItemFromView() cann't detect.
Custom views like XUI Views are "special", non native views.
B4X:
Dim SwB As SwiftButton = Sender
Dim xClVIndex as Int=ClVList.GetItemFromView(SwB.mBase)
mBase is the Panel on which the custom view is built.
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Custom views like XUI Views are "special", non native views.
B4X:
Dim SwB As SwiftButton = Sender
Dim xClVIndex as Int=ClVList.GetItemFromView(SwB.mBase)
mBase is the Panel on which the custom view is built.
After I have tested,it still has error.
Private Sub btnBadge_Click
badge = badge + 1
UpdateIcon("cart", AddBadgeToIcon(cartBitmap, badge))

'Dim xCLVIndex As Int = CLVList.GetItemFromView(Sender) 'Get the row index by using the sender filter

Dim SwB As SwiftButton = Sender
Dim xClVIndex As Int=CLVList.GetItemFromView(SwB.mBase)

Dim xCLVItem As B4XView = CLVList.GetPanel(xClVIndex) 'Get the Item layout for the selected Row
Dim LblNum As B4XView = xCLVItem.GetView(0) '1st view in the layout index which is LblNum
'Dim LblText As B4XView = xCLVItem.GetView(1) '2nd view in the layout index which is LblText
Dim LblText As B4XView = xCLVItem.GetView(3) '4th view in the layout index which is LblText

LblNum.TextColor = XUI.Color_Blue 'Change the font color to blue
LblNum.Text = Chr(0xF118) 'Put an icon in the label (a smiley)
LblText.TextColor = XUI.Color_Red 'Change the font color to red
LblText.Text = "be selled" 'Put new text in the label
End Sub
 
Upvote 0

rraswisak

Active Member
Licensed User
Longtime User
Add line 12 is a must !
Add line 12 is a must !:
Sub CLVList_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
    Dim ExtraSize As Int = 25 'Add 25 items at a time, this can be changed to suite your requirements
    For i = Max(0, FirstIndex - ExtraSize) To Min(LastIndex + ExtraSize, CLVList.Size - 1) 'Loop for adding/removing your items layout to or from the list
        Dim Pnl As B4XView = CLVList.GetPanel(i) 'Declare a new B4XView
        If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then 'Add a new item to the list
            If Pnl.NumberOfViews = 0 Then 'Add items to the list
                Dim TD As TestData = CLVList.GetValue(i) 'Get your custom Type
                Pnl.LoadLayout("ItemInfo") 'Load your
                'ImageView1.Bitmap=LoadBitmap(File.DirAssets, "glass.png")
                LblNum.Text = TD.LabelNum 'Self-explanatory
                LblText.Text = TD.LabelProduct 'Self-explanatory
                btnBadge.Tag = LblNum
                ImageView1.SetBitmap(XUI.LoadBitmapResize(File.DirAssets, TD.BitmapFile, ImageView1.Width, ImageView1.Height, True))
            End If
        Else 'Remove items from the list
            If Pnl.NumberOfViews > 0 Then
                Pnl.RemoveAllViews 'Remove none visible item from the main xCLV layout
            End If
        End If
    Next
End Sub

And modifiy the sub with this:
B4X:
Private Sub btnBadge_Click
    badge = badge + 1
    UpdateIcon("cart", AddBadgeToIcon(cartBitmap, badge))
   
    Dim sb As SwiftButton = Sender
    Dim xCLVIndex As Int = CLVList.GetItemFromView(sb.Tag)
    Dim LblNum As B4XView = CLVList.GetPanel(xCLVIndex).GetView(0)
    Dim LblText As B4XView = CLVList.GetPanel(xCLVIndex).GetView(1)
   
    LblNum.TextColor = XUI.Color_Blue 'Change the font color to blue
    LblNum.Text = Chr(0xF118) 'Put an icon in the label (a smiley)
    LblText.TextColor = XUI.Color_Red 'Change the font color to red
    LblText.Text = "be selled" 'Put new text in the label
End Sub

Doing the same way for another swift button... good luck
 
Last edited:
Upvote 0

rraswisak

Active Member
Licensed User
Longtime User
shop3a.gif
 
Last edited:
Upvote 0
Top