Skip to content

Instantly share code, notes, and snippets.

@nesquena
Last active August 29, 2015 13:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nesquena/8de33f701e387be0a80d to your computer and use it in GitHub Desktop.
Save nesquena/8de33f701e387be0a80d to your computer and use it in GitHub Desktop.
Generating an Android project in Eclipse sans Fragments.

Generate an Android Project in Eclipse

Eclipse recently started generating a fragment by default when a new project or activity is created which causes a bunch of issues.

Generate Project

First, generate your projects with minimum SDK 14 to avoid a few issues with the compatibility library:

Project

Remove Fragment XML

Next, we want to copy the contents of res/layout/fragment_main.xml and move them into res/layout/activity_main.xml and then delete the fragment XML file:

Remove fragment xml

Remove Placeholder Fragment

Finally we want to edit the src/com.../MainActivity.java file to remove the if statement and all inner contents from the onCreate and remove the definition of the PlaceholderFragment:

Remove placeholder

That's It

Now we have a project with an activity which we can use that does not require the use of fragments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment