Welcome to the Java Programming Forums


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.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Qusetion in android development

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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

    The first one: activity_main.xml

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.example.m003.MainActivity"
        tools:ignore="MergeRootFrame" />

    The second fragment_main.xml

     
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.example.m003.MainActivity$PlaceholderFragment" >
     
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello_world" />
     
    </RelativeLayout>

    Could any tell me what is the different between these two.

    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 ?


  2. #2
    Junior Member
    Join Date
    Jan 2015
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Qusetion in android development

    fragment.xml by default it is created dont do anything in that file that is fragment.xml just if u want to do drag and drop do it in the activit.xml

  3. #3
    Forum VIP
    Join Date
    Jun 2011
    Posts
    414
    My Mood
    Stressed
    Thanks
    52
    Thanked 119 Times in 100 Posts
    Blog Entries
    5

    Default 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

Similar Threads

  1. guideline do android development
    By aba muhammad in forum Android Development
    Replies: 2
    Last Post: November 6th, 2013, 07:37 AM
  2. Java Enterprise Development(J2EE) or Java Android Development?
    By gokhan47 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 1st, 2013, 09:27 PM
  3. Android Development
    By bgroenks96 in forum Java ME (Mobile Edition)
    Replies: 3
    Last Post: August 30th, 2013, 11:03 PM
  4. Android Development Career!!
    By diyaots in forum Android Development
    Replies: 4
    Last Post: July 1st, 2013, 07:54 AM