解析XML时出错:使用工具栏sdk 21的未绑定前缀

时间:2022-04-26 05:25:34

So, I installed the latest SDK 21 Lollipop release. I was having the actionbar activated with icons on in, and I am trying to recover it back using the new toolbar feature... but it seems not working properly. Basically I am following the information provided here

所以,我安装了最新的SDK 21 Lollipop版本。我正在使用图标激活操作栏,我正在尝试使用新的工具栏功能恢复它...但它似乎无法正常工作。基本上我遵循这里提供的信息

Basically, you need to create a toolbar instance in the layout. So did I:

基本上,您需要在布局中创建工具栏实例。我也是:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.Toolbar
   xmlns:app="http://schemas.android.com/apk/res-auto" 
   android:id="@+id/myapp_toolbar"
   android:layout_height="wrap_content"
   android:layout_width="match_parent"
   android:minHeight="20"
   android:background="@drawable/action_bar_myapp" />

However, this is creating and error message at the second line with the error message "error: Error parsing XML unbound prefix".

但是,这是在第二行创建和错误消息,并显示错误消息“错误:解析XML未绑定前缀时出错”。

When this error is happening (like in here) is usually due to having a wrong sintax, I copied/pasted directiyl from the webpage, also I made a simple test. By removing all android tags, the problem is still present.

当这个错误发生时(比如在这里)通常是因为有一个错误的sintax,我从网页上复制/粘贴了directiyl,我做了一个简单的测试。通过删除所有Android标签,问题仍然存在。

Probably is something very simple, but I am stucked. Any idea?

可能是非常简单的事情,但我被困住了。任何想法?

1 个解决方案

#1


13  

You have to declare the android namespace.

你必须声明android命名空间。

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.Toolbar
   xmlns:android="http://schemas.android.com/apk/res/android"   
   xmlns:app="http://schemas.android.com/apk/res-auto" 
   ....
/>

#1


13  

You have to declare the android namespace.

你必须声明android命名空间。

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.Toolbar
   xmlns:android="http://schemas.android.com/apk/res/android"   
   xmlns:app="http://schemas.android.com/apk/res-auto" 
   ....
/>