Error:(1) Error parsing XML: not well-formed (invalid token)

我是研究僧i 提交于 2019-12-14 02:38:09

问题


On right clicking the error "Error:(1) Error parsing XML: not well-formed (invalid token)" and then jump to source it opens the following activity_main.xml. I am not able to figure the error out

<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"/>

回答1:


Changing from FrameLayout to RelativeLayout in activity_main.xml solved the error, but I don't know how it worked and whats wrong in FrameLayout. But I got stuck to my previous problem , again I am getting no error messages but My app doesn't show any ListView when i run it on my device ,blank white screen with app name written on top appears on clicking the app icon in my device. Others who are having the same problem please help me and please check whether changing to RelativeLayout works or not.



来源:https://stackoverflow.com/questions/30797058/error1-error-parsing-xml-not-well-formed-invalid-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!