Recyclerview not call onCreateViewHolder

前端 未结 30 1361
离开以前
离开以前 2020-11-28 07:04

My RecyclerView does not call onCreateViewHolder, onBindViewHolder even MenuViewHolder constructor, therefore nothing app

30条回答
  •  無奈伤痛
    2020-11-28 07:49

    I struggled with this issue for many hours. I was using a fragment. And the issue was not returning the view. Below is my code:

    ProductGridBinding binding = DataBindingUtil.inflate( inflater, R.layout.product_grid, container, false);
    
    
    
        mLinearLayoutManager = new LinearLayoutManager(getActivity());
        mLinearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    
        binding.rvNumbers.setHasFixedSize(true);
        binding.rvNumbers.setLayoutManager(mLinearLayoutManager);
        binding.rvNumbers.setAdapter(adapter);
    
    
        View view = binding.getRoot();
    
    
        return view;
    

提交回复
热议问题