java.lang.IllegalStateException: RecyclerView has no LayoutManager in Fragment

后端 未结 5 1619
庸人自扰
庸人自扰 2020-12-30 06:50

I was in the process of changing an Activity into a Fragment and got the following error as soon as I inflated the RecyclerView.

@Override
public View onCrea         


        
5条回答
  •  时光取名叫无心
    2020-12-30 07:09

    Still null pointer exception even if I initialize it in onCreateView.

    Add it programatically.

    
    
    
      
    
    
    
    
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    
    ...
        // create recyclerview
    ...
                LinearLayout llContainer = (LinearLayout)  v.findViewById(R.id.llContainer);
                llContainer.addView(recyclerView);
    
                return v;
            }
    

提交回复
热议问题