Why is there no .xml file fragment in the ADT Bundle 20140702 package?

Following the instructions that Building a simple user interface on the Android Developers website, I am going to open the fragment_main.xml file from res / layout / with Eclipse. But based on the ADT Bundle 20140702 in res / layout only the activity_main.xml file is present. Or fragment_main.xml can be found on version 20140321.

+6
source share
4 answers

Depending on which IDE you are using, creating a mock fragment for your main action may be just now. If my memory serves me correctly, I believe that the automatically generated fragment was distributed in all IDEs at the time of writing the tutorial.

Just use the activity_main.xml file instead of this fragment_main.xml file, and the tutorial will work fine. OR you can also right-click on the layout folder and create a new XML layout file and call it fragmented_main.xml

+2
source

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

+1
source

When creating a new Android application project, select the option Empty action with fragment "on the page" Create an event ". Then we can find fragment_main.xml .

+1
source

I created a new fragment_main.xml file as described above, but make sure that in MainActivity.java you changed this line of code:
from
setContentView(R.layout.activity_main);
for the image setContentView(R.layout.fragment_main);

+1
source

Source: https://habr.com/ru/post/972158/


All Articles