Reputation: 6196
So I started diving into the Android world and was trying to follow the official getting started
guide from here: building-ui. The tutorial seems simple enough, but I'm running into issues where the things don't quite match up.
For example:
Why is this? What am I doing wrong? Is the documentation old? (I'm using Eclipse Juno
, and use Android 2.3 SDK
). I try to format (copy the code from the tutorals) exactly but when I try to run the app I get errors.
--
Tutorial says main.xml file is like this:
<?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" >
</LinearLayout>
.
.
.
My my_first_activity.xml looks like this:
<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" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:text="@string/hello_world"
tools:context=".MyFirstActivity" />
</RelativeLayout>
Upvotes: 2
Views: 3952
Reputation: 5980
Yeah, the documentation is a little old. You've got it right; they're the same file, with different names. You can safely rename it to main.xml if it makes you feel better.
You've picked the setting that creates a "hello world" text view by default, so it went ahead and created that TextView for you.
If you want, you can replace the RelativeLayout
with LinearLayout
to follow the tutorial. I don't think the part works in the new ADT.
Upvotes: 2
Reputation: 12643
Seems ADT (android development tools) were updated recently - refer to details about changes here . Probably, documentation wasn't updated the same time. The difference in layout files You've provided is not significant, so try to follow other steps of the tutorial using my_first_activity.xml.
Upvotes: 0