顶级元素未完成,Valid XML必须具有根标记:Android Studio

时间:2014-12-01 16:24:10

标签: android xml android-studio

我在android收到错误:title =“@ string / action_refresh”和android:title =“@ string / action_settings”说明顶级元素未完成且Valid XML必须有根标记。我该怎么做才能纠正这个错误?

Ffragment.xml:

<?xml version="1.0" encoding="utf-8"?>

<menu xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto">
  <item android:id="@+id/action_refresh"
    android:title="@string/action_refresh"
    app:showAsAction="never" />
</menu>

my.xml:     

<menu xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  tools:context=".MyActivity" >
  <item android:id="@+id/action_settings"
    android:title="@string/action_settings"
    android:orderInCategory="100"
    app:showAsAction="never" />
</menu>

的strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">My Application</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="action_refresh">Refresh</string>
</resources>

1 个答案:

答案 0 :(得分:0)

在此other question中,声明您只是用<root> </root> XML围绕。