【问题标题】:Error:(1) Error parsing XML: not well-formed (invalid token)错误:(1) 解析 XML 时出错:格式不正确(令牌无效)
【发布时间】:2015-08-28 02:36:44
【问题描述】:

右击错误“Error:(1) Error parsing XML: not well-formed (invalid token)”然后跳转到源它会打开以下activity_main.xml。我无法弄清楚错误

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    tools:context="com.example.utkarsh.beatle.app.MainActivity"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:ignore="MergeRootFrame"/>

Andoridmanifest.xml

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.utkarsh.beatle.app" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

fragment_main.xml

<FrameLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.example.utkarsh.beatle.app.MainActivity$PlaceholderFragment">

<ListView  android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/list_view_forecast" />

</FrameLayout>

activity_main.xml

<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
tools:context="com.example.utkarsh.beatle.app.MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="MergeRootFrame"/>

list_item_forecast.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:id="@+id/list_item_forecast_textview"/>

【问题讨论】:

  • 你能发布整个 XML 文件吗? (使用编辑按钮)
  • 向您发布完整的 xml ..这是一个格式良好的 xml..您可能还有其他错误
  • 您粘贴 XML 的方式似乎在

标签: android xml android-layout xml-parsing


【解决方案1】:

activity_main.xml 中从 FrameLayout 更改为 RelativeLayout 解决了该错误,但我不知道它是如何工作的以及有什么问题框架布局。但是我遇到了以前的问题,我再次没有收到任何错误消息,但是 我的应用程序在我的设备上运行它时没有显示任何 ListView空白屏幕显示应用程序名称点击我设备中的应用图标时会出现顶部。有同样问题的其他人请帮助我,请检查更改为 RelativeLayout 是否有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多