lPing7 lPing7 - 10 days ago 6
Android Question

RecyclerView does not show up on tabbed activity, but other views do

I have a layout with 1 textview and 1 recycler view. When this layout is opened both the text view and recycler view show up. However when I inflate this layout in Android Studio's default tabbed activity, only the textview is there.

Here's my onCreateView method for the tabbed activity

public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

View rootView = inflater.inflate(R.layout.activity_single, container, false);

return rootView;
}


The activity_single layout contains the textview and recyclerview.

These are the screenshots of the two activities:

enter image description here

enter image description here

Answer

Your are not setting up RecycleView in this fragment so it wont show any recycle view in that fragment

public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.activity_single, container, false);

       //Setup your recycle view here with its adapter

        return rootView;
    }