栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 移动开发 > Android

Android ViewPagerIndicator详解及实例代码

Android 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Android ViewPagerIndicator详解及实例代码

Android ViewPagerIndicator详解及实例代码

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

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

 
 
 
   
     
     
     
     
   
   
   
 
 

自定义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数组中。

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/158803.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号