【问题标题】:Error parsing XML: not well-formed (invalid token)解析 XML 时出错:格式不正确(令牌无效)
【发布时间】:2013-04-26 02:46:26
【问题描述】:

我正在android site 上做 android 教程
我在 EditText 处不断收到这些错误:解析 XML 时出错:格式不正确(无效标记),并且元素线性布局必须后跟属性规范 >/>

<LinearLayout 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"
android:orientation="horizontal"
tools:context=".MainActivity" 

<EditText
    android:id="@+id/editText1"
    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"
    android:onClick="sendMessage"/>

</LinearLayout>

我该如何解决这个问题?

【问题讨论】:

    标签: android eclipse


    【解决方案1】:

    试试:

    <LinearLayout 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"
    android:orientation="horizontal"
    tools:context=".MainActivity" >
    
    <EditText
        android:id="@+id/editText1"
        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"
        android:onClick="sendMessage"/>
    
    </LinearLayout>
    

    您在 LinearLayout 元素的末尾缺少结束 &gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-25
      • 1970-01-01
      • 2015-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多