2011-05-14 61 views
0

我真的很难过。我跟着this链接了解如何为我的视图创建自定义xml标记。据我所知,我做了一切正确的事情。但日食仍然甩error: No resource identifier found for attribute 'radius' in package 'com.theliraeffect.fantasy'自定义XML标签不会解决?

你们可以看看吗?

hexmap.xml

<com.theliraeffect.fantasy.HexMap xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:hexmap="http://schemas.android.com/apk/res/com.theliraeffect.fantasy" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    hexmap:radius="3"/> 

attrs.xml

<resources> 
    <declare-styleable name="HexMap"> 
     <attr name="radius"/> 
    </declare-styleable> 

</resources> 

以防万一(虽然我怀疑这有什么用它做)。

package com.theliraeffect.fantasy; 

import android.content.Context; 
import android.content.res.TypedArray; 
import android.util.AttributeSet; 
import android.view.View; 

public class HexMap extends View { 

    HexMap(Context context, AttributeSet attrs, int defstyle) { 
     super(context, attrs, defstyle); 
     TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.hexmap); 

     a.recycle(); 
    } 
} 
+0

作为一个方面说明:除了开始活动(我没有触及),这是整个项目。我开始了一个全新的项目来处理这个问题。 – AedonEtLIRA 2011-05-14 14:47:30

+1

从你提供的链接'非标准的android属性需要声明它们的类型',我猜测这意味着你必须在attrs.xml中为'radius'添加'format =“..”''。 – harism 2011-05-14 16:11:15

回答

0

@Harism - 谢谢,就是这样。我认为这个整数是一个默认设置,不需要指定。它现在有效。如果您将您的评论更改为答案,我会给您信用。

相关问题