i am really confused right now because whenever i create a new android app with blank activity it always comes out with fragment_main.xml.. i just wanted to create a blank a
For small projects, create a project without an activity and add/edit activities, layouts, and manifest manually.
While creating a new Application, just copy the Layout Name to the Fragment Layout Name (e.g. activity_main)
Voila!!! You get an activity without the fragment part.
Remove this portion of the code from activity:
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
Clean the project.
You can use the previous template by editing the template files inside the Android SDK folder. But, make sure you have a backup of the "BlankActivity" folder.
Go to /templates/tools/templates/activities/BlankActivity
Locate the template.xml file and locate the following piece of code
<parameter
id="fragmentLayoutName"
name="Fragment Layout Name"
type="string"
constraints="layout|unique|nonempty"
suggest="fragment_${classToResource(activityClass)}"
default="fragment_main"
help="The name of the layout to create for the activity's content fragment" />
and change the constraints
to constraints="empty"
.
Locate recipie.xml.ftl and locate the following piece of code
<instantiate from="res/layout/fragment_simple.xml.ftl"
to="${escapeXmlAttribute(resOut)}/layout/${fragmentLayoutName}.xml" />
and comment the whole line.
Locate SampleActivity.java.ftl file inside root/src/app_package and delete these two lines
<#include "include_options_menu.java.ftl">
<#include "include_fragment.java.ftl">
Locate fragment_simple.xml.ftl and activity_fragment_container.xml.ftl file inside root/res/layout. Copy the contents of fragment_simple.xml.ftl file to activity_fragment_container.xml.ftl file.
Now when you try to create a new activity, you'll get this screen
You can leave the Fragment Layout Name field blank.
This works fine for me in the case of blank activity. I'm not sure if this is the right approach, with discarding fragments and all, but this works for me.
We found a solution to this:
When you create a project select "empty" activity. Then it create a MainActivity class that extends Activity and an activity_main.xml layout.
In other words, it give you the behavior that was there before.
This worked in ADT 22.6.3.
Android heard our voice :).
Just upgrade or download ADT version to 23.0.2 or higher.
Now you can choose blank activity like this,
Thank you to the person that reported this, https://code.google.com/p/android/issues/detail?id=67513
This was my first glimpse into android-review.googlesource.com. Digging around I didn’t see a way to download the patch set that was put together and I’m unsure how to “cherry pick” tools_r22.6, If there's a thread that explains it a link would be appreciated.
Here’s how I went about it.
On your machine navigate to your SDK folder then \tools\templates\activities
Copy the BlankActivities folder and paste it into the same directory.
Rename BlankActivities_copy to EmptyActivities
Go to https://android-review.googlesource.com/#/c/88890/4
Under the Files section there is a list of links. Each link directs you to the xml that needs to be added to the new EmptyActivities folder you created.
Copy the xml from the right pane to the path\file at the top of the left pane(the link was also the path). If the file already exists delete the contents and replace. If the file doesn’t exist, create it and copy the xml into the file.
Repeat for each of the links.
Close and reopen Eclipse. If you have any of the files open in an editor Eclipse will crash.
Thank you to Josiah Gaskin at google with the unbelievable 2 day turnaround!
No training literature references the fragments in the BlankActivity. I’m sure this fix saved me countless hours trying to figure out how to navigate around fragments while trying to learn a new IDE. Thanks again.