Android的使用命名空间preFIX在库属性 [英] Android use namespace as prefix for attributes in library
问题描述
我试图通过支持库来实现的动作条,第7版。因为我想支持的Android 2.1(API 7级)及以上的应用程序。
I am trying to implement the ActionBar through the support library, v7. Because I want to support the app for Android 2.1 (API level 7) and above.
我读 http://developer.android.com/guide/topics /ui/actionbar.html 如下: 使用XML的支持库属性 请注意,showAsAction属性上面使用的标签定义自定义命名空间。使用由支持库定义的XML属性时,因为这些属性在旧设备的Android框架是不存在的,这是必要的。所以,你必须使用自己的名称空间为preFIX由支持库中定义的所有属性。
I read in http://developer.android.com/guide/topics/ui/actionbar.html following: "Using XML attributes from the support library Notice that the showAsAction attribute above uses a custom namespace defined in the tag. This is necessary when using any XML attributes defined by the support library, because these attributes do not exist in the Android framework on older devices. So you must use your own namespace as a prefix for all attributes defined by the support library."
我的问题是我怎么用我自己的名字空间为preFIX由支持库中定义的所有属性?
My question is how do I use my own namespace as a prefix for all attributes defined by the support library?
一步一步的解释请! //感谢。
Step by step explanation please! //Thanks.
推荐答案
下面是一个菜单的例子:
Here is an example of a menu:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:whatever="http://schemas.android.com/apk/res-auto">
<item
android:id="@id/wims_ab_done"
android:icon="@drawable/white_check_mark"
android:title="@string/save"
whatever:showAsAction="always"/>
<item
android:id="@id/wims_ab_items_remove"
android:icon="@drawable/wims_remove"
android:title="@string/remove"
whatever:showAsAction="always"/>
</menu>
整个理念是有 http://schemas.android.com/apk/res-auto
在根命名空间属性菜单
。不要紧,什么是命名空间标识,只要它是有效的,并在使用被用作这样的 showAsAction
属性。这是否回答你的问题?
The whole philosophy is to have http://schemas.android.com/apk/res-auto
in the namespace attribute in root menu
. It doesn't matter what is the namespace identifier as long as it's valid and is used as such when using showAsAction
attributes. Does this answer your question?
这篇关于Android的使用命名空间preFIX在库属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!