What's the difference between BaseAdapter and ArrayAdapter?

前端 未结 6 2081
轮回少年
轮回少年 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:18

    One more difference between BaseAdapter and ArrayAdapters is, if you extend array adapter you have to call super class constructor in the subclass constructor.

    UserListAdapter extends ArrayAdapter{
    
       List UserList;
       Context context;
    
       public UserListAdapter(Context context, int resource,List listUsers) {
         super(context, resource, listUsers);      /* Super class constructor is called */
         UserList = listUsers;
         this.context = context;
       }
    
    }
    

    But there is no super class for BaseAdapter. As BaseAdapter serves as super class for all other adapters

    UserListAdapter extends BaseAdapter{
    
       List UserList;
       Context context;
    
       public UserListAdapter(Context context, int resource,List listUsers) {
         /* No super class constructor */
         UserList = listUsers;
         this.context = context;
       }
    
    }
    

提交回复
热议问题