The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Qusetion in android development

hello everyone, I'm just starting to learn how to program in Android. However, I had a problem with emulator, but I fixed, and here come my question. in the ( layout ) Folder there are two xml files and I'm not sure why.

Note: When I create an ( Android Application Project ) they both created automatically

Also another thing, why another package is created with one that I all ready created? every time I create a new ( Android Application Project ). what I mean that in the ( src ) Folder I have one package, and in the ( gen ) there is another one. why I would need both of them ?

Re: Qusetion in android development

The Android toolkit creates a lot of fluff when you generate new projects which can be understandably confusing for new coders. Just realise it's there to give you clues about things you need to learn

First question; Fragments are little bits of UI. They are used to reuse components or glue individual components together. This has become all the rage lately because it encourages a DRY approach to your UI layouts. It's been a while since I created a project from scratch but it you have a look at MainActivity you will see references the Fragment and code to add it to to Layout.

Second question; all your source code lives in the /src folder. The /gen folder contains the auto-generated files such as compiled classes and the all important R.java which gives you programatically access to layouts and drawables. You will *never* need to work in /gen and it can break the project if you try to, so just stay away from it (occasionally you may do a Project -> Clean which regenerates /gen).

Computers are fascinating machines, but they're mostly a reflection of the people using them.
-- Jeff Atwood