开发者

Avoid some elements in a ArrayAdapter

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜