Android Question Cards list with CustomListView Example - Get Field value from Card

Kevin Hartin

Active Member
Licensed User
Hi Erel,

Your Card Example has been very helpful for me with my latest application however, I am at a loss as to how you can get a specific field value from a particular card. My cards are populated from a local database and I need a RecordID from the card to perform a SQL update operation.

I understand the concept of the index of the card, but with respect to your sample, how could I get the value for lblTitle.Text on the card with index 1, which should be "This is item #2"?

Thanks,
Kev
 

Kevin Hartin

Active Member
Licensed User
I have made what is probably a crude workaround by setting each cards Tag to the value I need and then using the index to access the panels Tag on a Click event.

However this will only work for a single value and I imagine there must be a way to read any view present on the card panel
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
I understand the concept of the index of the card, but with respect to your sample, how could I get the value for lblTitle.Text on the card with index 1, which should be "This is item #2"?

The code below edits the card title label ... It will work with the CardList Example.
It sounds like you have altered the card layout so you will need to adjust the index of panel views accessed. (you mention the title is view #2 (index 1)

B4X:
Sub lblAction1_Click
    Dim index As Int = CLV1.GetItemFromView(Sender)       
    Dim pnl1 As B4XView = CLV1.GetPanel(index)            'CLV base panel
    Dim pnl2 As B4XView = pnl1.GetView(0)                    'Card1 layout panel
    pnl2.GetView(3).Text = "This Item Title has been edited ! ... "    'view(3) = 4th label on panel...  refer order in Designer ViewTree for Item/Row layout
    
    'long way
    Dim img As B4XView= pnl2.GetView(2)
    img.SetBitmap(xui.LoadBitmapResize(File.DirAssets, "pexels-photo-446811.jpeg", ImageView1.Width, ImageView1.Height, True))
End Sub
 
Upvote 0

Kevin Hartin

Active Member
Licensed User
OK, so the views in the panel can only be referred to by index and the index is dependant on the order in the designer. Thanks, now I understand.

Is there anything wrong with my workaround of setting the Tag og the panel and using that?

Kev
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
Is there anything wrong with my workaround of setting the Tag og the panel and using that?

No. There is nothing wrong with your method... more for the fact you just want to Get the card title, not change it
 
Upvote 0
Top