码迷,mamicode.com
首页 > 移动开发 > 详细

java.lang.NoSuchMethodException: <init> [class android.content.Context, interface androidutil.Attri

时间:2015-07-22 18:56:01      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:自定义控件android   relativitylayout   常见错误   

<pre name="code" class="java"><span style="font-size:24px;">private int mIndex;
public HomeItem(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub

		mContext = context;
		TypedArray attrs_index = context.obtainStyledAttributes(attrs,
				R.styleable.attrs_index);//实现该属性
		mIndex = attrs_index.getInteger(R.styleable.attrs_index_index, 0);
		//此处执行初始化操作
	}</span>




</pre><pre name="code" class="java"><pre name="code" class="java"><span style="font-size:24px;">attrs.xml
<?xml version="1.0" encoding="utf-8"?>  
<resources>  
    <declare-styleable name="attrs_index">  
        <attr name="index" format="integer" />  
    </declare-styleable>  
</resources></span>





java.lang.NoSuchMethodException: <init> [class android.content.Context, interface androidutil.Attri

标签:自定义控件android   relativitylayout   常见错误   

原文地址:http://blog.csdn.net/woyaochenggong774/article/details/47005643

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!