Android自定义的属性的使用
获取引用类型的属性值
private void init(Context context, AttributeSet attrs) {
//int textId = attrs.getAttributeIntValue(NAME_SPACE,"text");
//String string = getResources().getString(textId);
//Log.e("UserViewView", "UserViewView init()" + textId);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.UserViewView);
int resourceId = ta.getResourceId(R.styleable.UserViewView_text, 0);
String string = getResources().getString(resourceId);
Log.e("UserViewView", "UserViewView init()"+string);
//回收
ta.recycle();
}
<declare-styleable name="UserViewView">
<attr name="text" format="reference"/>
</declare-styleable>
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.registItemView);
String item_left = typedArray.getString(R.styleable.registItemView_item_left);
String item_btn_right = typedArray.getString(R.styleable.registItemView_item_btn_right);
String item_center = typedArray.getString(R.styleable.registItemView_item_center);
boolean item_btn_right_is_gone =
typedArray.getBoolean(R.styleable.registItemView_item_btn_right_is_gone, false);
boolean item_ib_right_is_gone =
typedArray.getBoolean(R.styleable.registItemView_item_ib_right_is_gone, false);
//获取引用类型的值
int itemBottomResourceId = typedArray.getResourceId(R.styleable.registItemView_item_bottom, 0);
String item_bottom = context.getString(itemBottomResourceId);
int item_input_type =
typedArray.getInt(R.styleable.registItemView_item_input_type, InputType.TYPE_CLASS_TEXT);
//释放
typedArray.recycle();
Android自定义的属性的使用的更多相关文章
- android自定义view属性
第一种 /MainActivity/res/values/attrs.xml <?xml version="1.0" encoding="utf-8"?& ...
- Android自定义XML属性以及遇到的命名空间的问题
转载请注明出处:http://www.cnblogs.com/kross/p/3458068.html 最近在做一些UI,很蠢很蠢的重复写了很多代码,比如一个自定义的UI Tab,由一个ImageVi ...
- android 自定义View属性
在android开发过程中,用到系统的View时候可以通过XML来定义一些View的属性.比如ImageView: android:src 和android:scaleType为ImageVie ...
- android自定义视图属性(atts.xml,TypedArray)学习
是一个用于存放恢复obtainStyledAttributes(AttributeSet, int[], int, int)或 obtainAttributes(AttributeSet, int[] ...
- Android自定义XML属性
<?xml version="1.0" encoding="utf-8"?> <resources> <declare-style ...
- Android之探究viewGroup自定义子属性参数的获取流程
通常会疑惑,当使用不同的布局方式时,子view得布局属性就不太一样,比如当父布局是LinearLayout时,子view就能有效的使用它的一些布局属性如layout_weight.weightSum. ...
- Android读取自定义View属性
Android读取自定义View属性 attrs.xml : <?xml version="1.0" encoding="utf-8"?> < ...
- Android 自定义view中的属性,命名空间,以及tools标签
昨日看到有人在知乎上问这3个琐碎的小知识点,今天索性就整理了一下,其实这些知识点并不难,但是很多开发者平时很少注意到这些, 导致的后果就是开发的时候 经常会被ide报错,开发效率很低,或者看开源代码的 ...
- Android自定义视图一:扩展现有的视图,添加新的XML属性
这个系列是老外写的,干货!翻译出来一起学习.如有不妥,不吝赐教! Android自定义视图一:扩展现有的视图,添加新的XML属性 Android自定义视图二:如何绘制内容 Android自定义视图三: ...
随机推荐
- C# ACCESS 查询提示“至少一个参数没有被指定”问题
错误的SQL指令如下: sqlStr = “select * from tb_userInfo where userName=” + userName; //错误的 sql 指令 正确的SQL ...
- 在 Visual Studio中 将 Objective-C 编译为 C++
快速使用Romanysoft LAB的技术实现 HTML 开发Mac OS App,并销售到苹果应用商店中. <HTML开发Mac OS App 视频教程> 土豆网同步更新:http: ...
- Qt中加载Libevent静态库(通过reimp和rs两条语句将lib转为a)
文章来源:http://blog.sina.com.cn/s/blog_731bf4c90102wnpr.html 本文仅是个人经验总结,若有错误欢迎指教! 最近要做一个跨平台的项目,同时也涉及到网络 ...
- Delphi Berlin 10.1.2 FMX用TMessageManager处理自定义消息
看FMX代码,发现有两种消息处理的实现方式,一种是用TMessageManager来实现自定义的消息,另外一种象TEdit中的实现,直接声明消息方法. 早前,看过文章说TMessageManage ...
- QtStaticBuildScript(会有这么容易)
https://github.com/dankrusi/QtStaticBuildScript
- Oracle高级查询、事物、过程及函数
一.SQL函数 1.分类:单行函数(日期.数值.转换.字符等),多行函数,也称为分组函数(max.min.avg.sum.row_number.rank等). 2.数值函数 abs(n):求数字n的绝 ...
- grub密码
[root@lnmp ~]# grub-md5-cryptPassword: Retype password: $1$k9fQ//$Fh3/O8i3.9dw4zarIHtIx1 [root@lnmp ...
- 【转】 远程连接mysql
转自:http://www.linuxidc.com/Linux/2013-05/84813.htm 1.确认能ping通 2.确认端口能telnet通.如果user表的host值是localhost ...
- 上不了名校?可以在 GitHub 上读他们的课程
今天开始,全国各大区域的高考成绩陆续公布,又到了几家欢喜几家愁的时刻,如果你准备报考计算机相关专业,但是又由于分数不高而苦恼.别担心,在 GitHub 上有着大量的名校教学资源,即使上不了名校,也可以 ...
- python Trojan 模块(我忘记几了)—— 通信隧道建立
0X01 SSH的建立 我想,第一步先实现简单的ssh通信再说,类似其他那种高端的C&C将逐步研究 对于ssh,python有个module叫paramiko,对没错看起来像日语单词 The ...