My first app. Error: Invalid start tag LinearLayout. Why?
It was working perfectly but then I made some minor edits and now it isn't working... Here's the main layout xml file... It gives an error in line 3.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="6">
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="2"
android:background="#FFFF00"
android:text="@string/yellow"
android:textColor="#FFFFFF"
android:gravity="center_horizontal"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="#FFFFFF"
android:text="@string/helo"
android:textColor="#000000"
android:gravity="center_horizontal"
/>
<Te开发者_高级运维xtView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="#FFFF00"
android:text="@string/yellow"
android:textColor="#FFFFFF"
android:gravity="center_horizontal"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="4">
<TextView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:text="@string/blue"
android:layout_weight="3"
android:textColor="#FFFFFF"
android:background="#0000FF" />
<TextView
android:background="#FFFFFF"
android:text="@string/helo"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:textColor="#000000"
android:layout_weight="1" />
<TextView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:textColor="#FFFFFF"
android:text="@string/yellow"
android:background="#FFFF00" />
<TextView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:text="@string/blue"
android:background="#0000FF"
android:textColor="#FFFFFF" />
</LinearLayout>
</LinearLayout>
I think that you have your file in the wrong directory. The layout file should be in a res/layout/
directory within your project. My guess is that you have it in some other res/
directory.
Try @CommonsWare's suggestion. If that doesn't work, try deleting the error messages in Eclipse. (i.e. right-click and select delete.) I often find I fix a problem in XML layouts but the IDE doesn't notice, and keeps reporting the error preventing me from compiling. Just deleting the error message can fix this in this case. If that doesn't work, try making a clean build.
精彩评论