user1478754
user1478754

Reputation: 15

Android ListView Item Visibility

I'm trying to create a screen that displays multiples items. For this, I've created a listview but I'm not sure how to approach how to add/remove items from it. Since I'm using custom listview items, I've created my own listadapter but now I need a way to add items on a button click.

Is there a way to create listview that can take an indefinite amount of items (instead of passing it in an fixed length array of View objects)? Also what's the best way to remove items from listviews? setVisibility?

Upvotes: 0

Views: 219

Answers (2)

Ankitkumar Makwana
Ankitkumar Makwana

Reputation: 3485

when you add item and remove item from list then need to notify adpter so

adapter.notifyDataSetChenged();

or in List you can add no of item

Upvotes: 1

Geralt_Encore
Geralt_Encore

Reputation: 3771

Add new items to your data and use:

adapter.notifyDataSetChenged();

You can also remove items this way

Upvotes: 0

Related Questions