Android Question I am confused: xCustomListView, B4XImageView, Tag?

doncx

Active Member
Licensed User
Longtime User
In an xCustomListView with just several list items, each has a panel with a number of B4XViews, among them a button and a B4XImageView.

When you tap the button, you can then take a photo with simple camera intent. I store the resized bitmap into the database and also create a jpg file. It's also still in memory. Pretty simple.

Then I want to replace the bitmap of the B4XImageView with the new photo in the item/index where the button was pressed.

I can't figure out how to address the B4XImageView of the proper index in the CLV. I've managed to replace the last one, but not the proper one.

I'm storing the CLV index of the button pressed, but can't get to the correct B4XImageView with it. Don't know how to do it. Don't seem to fully understand TAGS despite trying.

I've tried many, many things.

I don't think there's a point in posting code.

My question is simple: How do I locate and address a B4XImageView in an xCLV item of a certain index?

Any help is most appreciated, including links for informative reading.
 
Solution
I don't think there's a point in posting code.
Yes, there is a point in posting your code and also your items layout to see where the B4XImageview fits in the hierarchy of the tree. But I am going to take a stab at it anyway:
Suppose the B4XImageview is the 2nd view in the panel that holds the button and the B4XImageview
B4X:
Dim pnl As B4XView = CustomListView1.GetPanel(index)  'index is the stored index from your button
Dim b4xiv As B4XImageView = pnl.getview(0).GetView(1).Tag 'B4XImageView is 2nd view on the panel
'pnl.getview(0)   refers to the panel on your layout holding the button and the B4XImageview. 
'GetView(1).Tag  refers to the B4XImageview.  This can be different depending on your views positions on the tree...

Mahares

Expert
Licensed User
Longtime User
I don't think there's a point in posting code.
Yes, there is a point in posting your code and also your items layout to see where the B4XImageview fits in the hierarchy of the tree. But I am going to take a stab at it anyway:
Suppose the B4XImageview is the 2nd view in the panel that holds the button and the B4XImageview
B4X:
Dim pnl As B4XView = CustomListView1.GetPanel(index)  'index is the stored index from your button
Dim b4xiv As B4XImageView = pnl.getview(0).GetView(1).Tag 'B4XImageView is 2nd view on the panel
'pnl.getview(0)   refers to the panel on your layout holding the button and the B4XImageview. 
'GetView(1).Tag  refers to the B4XImageview.  This can be different depending on your views positions on the tree 
b4xiv.bitmap =  whatever bitmap you got when you clicked the button
This is the best I can do without you posting anything
 
Upvote 0
Solution

doncx

Active Member
Licensed User
Longtime User
Mahares - Once again, I thank you for your valuable assistance.

Two things were throwing me off.

1) I was sending a button to the back when hiding it and this was throwing the z-order of views off. I didn't understand why they were changing. I still don't know why but at least I've come to understand the behavior. So, all the views in the list item were changing their z-order. It turns out that it was unnecessary to send the button to the back so I'm no longer doing that.

2) I didn't know when to use .Tag and when not. For now, I'm using this rule and it appears to work: "If the view is platform-native but declared as B4XView, then DON'T use tag. However, if the view is a B4XCustomView then DO use .tag."

I will work harder to post my code in the future. It can take a lot of time to prepare a generic and reduced version of code for forum posting.

For what it's worth, I do think it's a shame that finding views in code is difficult, or perhaps sometimes not possible.

Again, thanks for your help. Your post pointed me in the right direction and with some additional empirical discovery I've advanced my knowledge.
 
Upvote 0
Top