Display a RecyclerView in Fragment

后端 未结 4 2157
离开以前
离开以前 2020-12-04 06:25

I\'m trying out the new RecyclerView in Android Lollipop and I\'m stuck.

I\'m trying to receive a list, with an icon and a TextView to the

4条回答
  •  臣服心动
    2020-12-04 06:51

    Make sure that you have the correct layout, and that the RecyclerView id is inside the layout. Otherwise, you will be getting this error. I had the same problem, then I noticed the layout was wrong.

        public class ColorsFragment extends Fragment {
    
             public ColorsFragment() {}
    
             @Override
             public View onCreateView(LayoutInflater inflater, ViewGroup container,
                 Bundle savedInstanceState) {
    
    ==> make sure you are getting the correct layout here. R.layout...
    
                 View rootView = inflater.inflate(R.layout.fragment_colors, container, false); 
    

提交回复
热议问题