A
A
Artem2013-01-04 15:26:13
Android
Artem, 2013-01-04 15:26:13

Filtering a custom ListView?

I have a ListView with a custom adapter from ArrayAdapter, where each element is an object with several properties. The data in the ListView is loaded from the network periodically at a specified interval. It is necessary to implement an enable/disable filter by two numeric values ​​inside the object.
To implement this, I created my own filter inside the adapter. But this approach does not work quite the way we would like. Firstly, apparently it changes the contents of the adapter, and secondly, it does not take into account freshly added data. And I would like to have a filter that simply hides the rows that do not match the condition when turned on, without affecting the true contents of the ListView in any way. However, I have not been able to find methods to hide individual rows. Are there built-in tools to implement this? If not, what is the best way to implement it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vovkab, 2013-01-05
@vovkab

1. No need to put into the adapter what should not be shown.
2. Even if you put it in, the filter should help, so deal with the filter, maybe something is wrong in the code.

A
Artem, 2013-01-06
@bartwell

Well, not easy: with the filter enabled, you will have to clear the ListView, refill it with all entries and call the filter every time you add entries ... Well, the approach seems to be clear, thanks for the help.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question