开发者

Avoid some elements in a ArrayAdapter

开发者 https://www.devze.com 2023-03-30 07:39 出处:网络
I\'m trying to implement a custom ArrayAdapter for a ListView. The ArrayList I want to adapt have s开发者_高级运维ome positions I want to ignore. (for example when myobject.getValue()>20) how can I i

I'm trying to implement a custom ArrayAdapter for a ListView.

The ArrayList I want to adapt have s开发者_高级运维ome positions I want to ignore. (for example when myobject.getValue()>20) how can I indicate that object shouldn't appear in the ListView?

Returning null in the method getView result in a nullPointerException

public View getView(int position, View convertView, ViewGroup parent)

Thanks in advance


Filter out your list before you create the adapter. Go through the original list, checking values, and only add the ones you need to a second list. Then use the second list for your adapter.

0

精彩评论

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