当我们需要自定义控件的时候经常会使用到TypedArray这个类,使用完之后必须调用recycler()函数。。。。

 但是如何获取呢?

 有如下几个方式:

  context(实际最后调用的是context.getTheme()的方法)

  1.obtainStyledAttributes (int[] attrs)

 

  2.obtainStyledAttributes (int resid, int[] attrs)

  3.obtainStyledAttributes (AttributeSet set, int[] attrs);(常用)

 

  4.obtainStyledAttributes (AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes)(常用)

  Resoureces  

  5.context.getResources.obtainAttributes(AttributeSet set, int[] attrs)

  详细解释参考:http://blog.csdn.net/zjh_1110120/article/details/50991560

 

posted on 2016-10-27 10:32  向着大牛奋斗  阅读(436)  评论(0编辑  收藏  举报