I have always had problem with the root layout. in the paragraph below, you must return a View from this method that is the root of your fragment’s layout.
onCreateView()
The system calls this when it’s time for the fragment to draw its user interface for the first time. To draw a UI for your fragment, you must return a View from this method that is the root of your fragment’s layout. You can return null if the fragment does not provide a UI.
what is the root of a fragment’s layout? is it the main_activity.xml or the layout file that define this specific fragment?
It’s the layout file which needs to be displayed in the
Fragment. We can it as a parent of all the views and layout that need’s to be displayed in theFragmentThere must be only one root element and it must contain the xmlns:android attribute with the android namespace as shown.
xmlns:android="http://schemas.android.com/apk/res/android"Hope this helps 🙂
Added: The onCreateView() method in your case should return layout file that define this specific fragment