开发者

Skip a getView in Android

开发者 https://www.devze.com 2023-01-30 16:47 出处:网络
I currently 开发者_StackOverflow中文版have a custom listview in Android that I generate by overriding the getView method of ArrayAdapter. It works perfectly. However, in certain cases I need to \"skip

I currently 开发者_StackOverflow中文版have a custom listview in Android that I generate by overriding the getView method of ArrayAdapter. It works perfectly. However, in certain cases I need to "skip" an item in the list. I tried returning null, but that just gives a nullpointer error. So my question is, what can I return in getView, so that no new item is added to the list?


You could use a custom Filter.

If you have a custom ArrayAdapter you can implement a custom filter and it will filter your list by a certain criteria and then those items won't even show and won't call getView to begin with.

If this sounds like it would work for you and want some more information or example code let me know.


How about setting the visibility property of your item to View.GONE? That should do it. If there is a better way to do it, I don't know it

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号