什么是绑定preFIX的意思是,解析XML是什么时候? [英] What does unbound prefix mean, when parsing XML?

查看:173
本文介绍了什么是绑定preFIX的意思是,解析XML是什么时候?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个XML文件中的我的Andr​​oid应用程序的自定义部件和错误是:

I Have made a xml file in my android app for the Custom Widget and the error is:

错误解析XML:绑定preFIX

Error parsing XML: unbound prefix

下面是我的XML文件:

Here is my xml file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <com.example.CustomWidget.MyView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"

        android:id="@+id/surface"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:layout_weight="1"/>

</LinearLayout>

com.example.CustomWidget 是我的包的名称, MyView的是我的类文件,其中的名我做了定制的小部件

com.example.CustomWidget is the name of my package and MyView is the name of my class file where I made the custom Widget.

推荐答案

第二个XML命名空间是完全正确这是你的自定义窗口小部件的命名空间,所以你需要适当定义命名空间:

The second XML namespace is correct however it is the namespace of your custom widget so you need to define the name space appropriately:

xmlns:android="http://schemas.android.com/apk/res/android"

变成了:

xmlns:mynamespace="http://schemas.android.com/apk/res/com.myproject.myprojectname"

此后任何自定义属性定义元素自定义视图将被简称为:

Thereafter any custom attribute elements you define for your custom view will be referred to as:

mynamespace:my_defined_attribute="success"

而不是:

android:layout_width="fill_parent"

这篇关于什么是绑定preFIX的意思是,解析XML是什么时候?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆