By default, when you create a new Android application project on your ecclipse IDE, the default layout name is
activity_main.xml
This is an empty xml layout.
So, you need to encode your fragment_main.xml in the res/layout/ directory, according to your implementation chosen by Android developers
steps - right-click res/layout/ > select new > new android xml file >, specify the file name as fragment_main.xml and write your code in it
or
right click activity_main.xml> refactoring > rename to fragment_main.xml
source share