Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ADT: No fragment_main.xml, only activity_main.xml

I'm trying to learn how to program android applications, so I downloaded the ADT bundle that google supplied, and I tried following the tutorial that allowed me to create a simple application. However, during the procedures, there are several instructions telling me to open up the fragment_main.xml file, but my layout/res/ directory did not have this file, only the activity_main.xml file. Furthermore, when creating new Android activities, there was never an option to name my fragment layout, indicating that eclipse just doesn't create it for some reason. I didn't think this would be an issue at first (I just edited activity_main instead), until I realized that the tutorial wanted us to use the some information from the fragment class or xml file.

Does anyone know why my Eclipse IDE is not creating a fragment_main.xml? I will try to supply more details if necessary.

like image 989
john.zli Avatar asked Mar 23 '14 02:03

john.zli


3 Answers

While creating the new Android Project in one of the panels select "Blank activity with Fragment" instead of default selection "Blank Activity". The Android Developer tutorial does not say anything about it. Doing so will create the file fragment_main.xml in res/layout/ which is needed to continue subsequent steps.

like image 142
old_soul_on_the_run Avatar answered Oct 12 '22 09:10

old_soul_on_the_run


Based on the versions you indicated in the comment response, I think updating to the later versions (22.6+) would help, as discussed in https://code.google.com/p/android/issues/detail?id=67421

like image 38
Prabindh Avatar answered Oct 12 '22 09:10

Prabindh


Try creating a new project with "Blank Activity with Fragment". I hope this is helpful.

like image 33
intellectual_stretch Avatar answered Oct 12 '22 11:10

intellectual_stretch