资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

AndroidViewPagerIndicator详解及实例代码

Android ViewPagerIndicator详解及实例代码

成都创新互联成都网站建设按需制作,是成都网站建设公司,为成都三轮搅拌车提供网站建设服务,有成熟的网站定制合作流程,提供网站定制设计服务:原型图制作、网站创意设计、前端HTML5制作、后台程序开发等。成都网站制作热线:028-86922220

关于自定义View的属性零碎知识

自定义View和自定义属性的知识不再此提及,这里着重说的是属性在自定义View中的获取方式,自定义的属性如下:

<?xml version="1.0" encoding="utf-8"?> 
 
 
   
     
     
     
     
   
   
   
 
 

自定义View的相关代码如下:

public CustomView(Context context, AttributeSet attrs) { 
  super(context, attrs); 
  TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Wisely); 
  typedArray.getBoolean(R.styleable.Wisely_wisely_1, true); 
  typedArray.recycle(); 
} 

重点看R.styleable.Wisely,它返回的是一个数组,而R.styleable.Wisely_wisely_1表示的则是数组的索引,它们在R文件中的表示如下:

public static final class attr { 
  public static final int wisely_1 = 0x7f010000; 
 
  public static final int wisely_2 = 0x7f010001; 
 
  public static final int wisely_3 = 0x7f010002; 
 
  public static final int wisely_4 = 0x7f010003; 
 
  public static final int wisely_out = 0x7f010004; 
 
} 
 
public static final class styleable { 
  public static final int[] Wisely = { 0x7f010000, 0x7f010001, 
      0x7f010002, 0x7f010003 }; 
 
  public static final int Wisely_wisely_1 = 0; 
 
  public static final int Wisely_wisely_2 = 1; 
 
  public static final int Wisely_wisely_3 = 2; 
 
  public static final int Wisely_wisely_4 = 3; 
} 

从上面可以看出一点,wisely_out也是attrs.xml中的属性,不过它是写在以Wisely命名的标签之外的,所以并未列入到styleable类的Wisely数组中。

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!


当前标题:AndroidViewPagerIndicator详解及实例代码
分享地址:http://cdkjz.cn/article/joscie.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220