<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>






posted on 2017-05-02 09:38  lxjshuju  阅读(172)  评论(0编辑  收藏  举报