【问题标题】:Description Resource Path Location Type error: Error parsing XML: not well-formed?说明资源路径位置类型错误:解析 XML 时出错:格式不正确?
【发布时间】:2015-05-10 08:29:41
【问题描述】:

这是我的一段代码。我有这个错误:

Description Resource    Path    Location    Type

错误:解析 XML 时出错:格式不正确(无效令牌)private.xml /private/res/layout 第 12 行 Android AAPT 问题

<LinearLayout android:xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:orientation="horizontal">
    <Button android:id="@+id/configure_cancel_button"
            android:text="Cancel"
            android:textColor="#fff"
            android:textStyle="bold"
            android:layout_weight="0.5"
            android:layout_width="0dip"
            android:layout_height="50dip" 
            android:layout_margin="10dip"
            android:paddingTop="5dip"
            android:paddingBottom="5dip"
            android:background="@drawable/cancel_selector" />
    <Button android:id="@+id/configure_confirm_button"
            android:text="Confirm"
            android:textColor="#fff"
            android:textStyle="bold"
            android:layout_weight="0.5"
            android:layout_width="0dip"
            android:layout_height="50dip" 
            android:layout_margin="10dip"
            android:paddingTop="5dip"
            android:paddingBottom="5dip"
            android:background="@drawable/confirm_selector" />
</LinearLayout>

【问题讨论】:

  • 哪一行是/private/res/layout/private.xml中的第12行?

标签: java android xml eclipse


【解决方案1】:

第一行不正确。

&lt;LinearLayout android:xmlns:android="http://schemas.android.com/apk/res/android"

应该是:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

去掉“xmlns”前的“android:”

【讨论】:

  • 我要注意的另一件事是,使用 IDE(例如 Eclipse、Android Studio)的 XML 生成能力可以轻松解决此类问题。即使您实际上不会使用生成的代码,也可以将您的代码与您所提供的模板进行比较,因为您知道它们提供的模板必须具有正确的语法。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-22
  • 1970-01-01
相关资源
最近更新 更多