Android Question Dynamic creation of bitmaps within ListView

MoraviaVenus

Member
Licensed User
Longtime User
Hi all,

I want to ask you, whether it is possible to dynamically change the content of bitmap placed in list view (using command .AddTwoLinesAndBitmap).

Particularly, I wanna put a bitmap to listview, which is similar but different for every item in listview, i.e. has same background but different foreground. See attached bitmaps, with clouds and numbers on them. The cloud is always the same, I just change the number of cloud every time (for every record).



Is there a possibility in B4A to make such a listview without the need to create 99 separate bitmaps?

In my application, I will change the count of numbered clouds dynamically based on user preferences.

Thank you for help.
 

MoraviaVenus

Member
Licensed User
Longtime User
Hi DonManfred,

thank you for recommendation. Could you please be more specific, what is it "customlistview"? Is it library? Or class? Or...?

Little example or link to related forum would be perfect !

Thank you.
 
Upvote 0

MoraviaVenus

Member
Licensed User
Longtime User
Hi DonManfred,

thank you for link. Helped a lot.

I can create the custom list view without problems, the problem starts, when I want to remove the custom list view. In Erel's example there was no function for removing the whole view, just the items inside of view.

When I am removing items one-by-one (using .RemoveAt), background remains

When I use function .Clear to remove all items, background still remains

Please, how can I elegantly remove whole custom list view?

Thank you.
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
all panels and views are displayed within a ScrollView . The CustomListView directly does not have a Visible property.

in the CustomListView Class Globals set variable " sv As ScrollView " to Public then from your Activity call ...

B4X:
  clv1.sv.Visible = False
 
Last edited:
Upvote 0

CidTek

Active Member
Licensed User
Longtime User
With a listview you need to create 99 single images to get what you want.
But you can use a customlistview and use ONE bitmap (the cloud) for the items and put a label on front of it which will get the numbers as caption...

It is much better to use a canvas to hold a single bitmap and then use canvas.drawtext to add the text to the canvas.

Do this in the loop that you use to add to your Listview
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…