What's the difference between BaseAdapter and ArrayAdapter?

前端 未结 6 2091
轮回少年
轮回少年 2020-12-07 09:42

I want to know the difference between using BaseAdapter and ArrayAdapter.

I have been achieving what I want through ArrayAdapters

6条回答
  •  一向
    一向 (楼主)
    2020-12-07 10:22

    BaseAdapters are more minimal and customizable. ArrayAdapters implement the most general uses of ListAdapters, but sometimes they are not enough.

    However, almost everything can be achieved by the use of ArrayAdapters. If your lists are already working by using ArrayAdapter correctly, you have nothing to gain from BaseAdapter.

    However, if you are storing your Context, Arrays or Lists in your ArrayAdapter implementation, maybe you'll want to switch to BaseAdapter, as ArrayAdapter already has them implemented.

    Anyway, if you're doing that, you can always remove those items, and resort to using getItem() to get the Array items, getCount() to get the size of the array, and getContext() to inflate your views.

提交回复
热议问题