CustomArrayAdapter Implementation:Unable to get the resource id

前端 未结 4 563
走了就别回头了
走了就别回头了 2021-01-19 01:12

I want to implement CustomArrayAdapter and following is the constructor I have written for my custom adapter

public CustomUsersAdapter(Context context, Array         


        
4条回答
  •  被撕碎了的回忆
    2021-01-19 02:03

    You need to us your layout file in that constructor. So you need to change your constructor from

    public CustomUsersAdapter(Context context, ArrayList users) {
        super(context, 0, users);
     }
    

    to

    public CustomUsersAdapter(Context context, int resLayout , ArrayList users) {
        super(context, resLayout , users);
     }
    

    resLayout is the ID for your layout xml file which will be in your custom adapter class.

    And the Syntax for ArrayAdapter is

    public ArrayAdapter (Context context, int resource, T[] objects)
    

    For more info you can check this

提交回复
热议问题