SundayMonday
SundayMonday

Reputation: 19737

main.xml is missing in new Android project - Eclipse OS X

I'm following this Android tutorial. I'm trying to find main.xml however it's not in res/layout. I do have res/layout/activity_my_first.xml however the root node of this file is RelativeLayout not LinearLayout like in the tutorial. How can I get main.xml?

Perhaps I can just create it myself. Or perhaps the XML file I do have is a replacement for main.xml in newer versions of the ADT Plugin. I'm brand new to Android and Eclipse so I'm a bit stuck.

Cheers!

Upvotes: 2

Views: 7369

Answers (2)

Mario
Mario

Reputation: 2739

You can just replace what's in your activity_my_first.xml with what's in the tutorial.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal">
    <EditText android:id="@+id/edit_message"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:hint="@string/edit_message" />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/button_send" />
</LinearLayout>

or create another xml called main.xml. The tutorial assumes you already have that created im guessing.

Just make sure in your onCreate method in your activity you have

setContentView(R.layout.activity_my_first);

Upvotes: 1

ab11
ab11

Reputation: 20100

Having a layout titled "main.xml" is unnecessary. If you like, you could create a file called main.xml in your res/layout folder, and copy and paste the layout in your sample - and it will then be available for use in code. But, unless you attempt to use a layout called "main" in your java code, it is unnecessary to have one in your project.

Upvotes: 1

Related Questions