Custom Adapter getView() method is not called

后端 未结 6 1329
悲&欢浪女
悲&欢浪女 2020-11-22 09:49

Here is the code of the fragment in which I am setting a custom adapter to the list.

There no errors but the ListView is empty. I have implemented

6条回答
  •  面向向阳花
    2020-11-22 09:49

    What you have been doing is

    In your adapter

    public CarListAdapter(Context context , ArrayList items) {
    
        this.context = context;
        this.items = items;
    
    }
    

    in your Fragment

    adapter = new CarListAdapter(getActivity(),ServiceCarListFragment.this.carDetailList);
    

    I hope you will be using FragmentActivity

    You need to call

    adapter = new CarListAdapter(YOUR_ACTIVITY_CONTEXT, carDetailList);
    

    where YOUR_ACTIVITY_CONTEXT will be your FragmentActivity

提交回复
热议问题