B
B
boomwest2014-12-19 15:42:21
Android
boomwest, 2014-12-19 15:42:21

How to track the change in the number of items in a ListView?

The fragment has a ListView and elements after it (buttons), the data is taken from the adapter. The adapter can add/remove data to the ListView.
Changes are tracked via notifyDataSetChanged() and the ListView updates fine.
The problem is that the fragment is in a ScrollView, because you need to be able to scroll the entire ListView and the buttons after it. The height of the ListView is set programmatically (number of items * height of the item).
But if the ListView is updated, then you need to track this change and re-adjust the height of the ListView (new number of items * item height). How do you know that the ListView has changed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bimeg, 2014-12-19
@boomwest

Especially for this, we came up with a header & footer view in the sheet;
addHeaderView
addFooterView

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question