android setTag的妙用和The key must be an application-specific resource id 异常
来源:互联网 发布:玩minecraft学编程 编辑:程序博客网 时间:2024/05/16 13:00
tag是view的一个属性,也可以说是view用于存放参数的一个map,对于提高性能和参数传递都有妙用,比如提高listview的性能:
用于缓存item的view
- public View getView(final int position, View convertView, ViewGroup parent) {
- ItemViewHolder holder;
- if (convertView == null) {
- holder = new ItemViewHolder();
- convertView = LayoutInflater.from(context).inflate(R.layout.view_item, null);
- holder.timeTextView = (TextView) convertView.findViewById(R.id.text_item_content_time);
- holder.remarkTextView = (TextView) convertView.findViewById(R.id.text_item_content_remark);
- convertView.setTag(holder);
- } else {
- holder = (ItemViewHolder)convertView.getTag();
- }
- if(mMessageListGroup.get(mMessageList.get(position).getGroupId()).isShown()){
- convertView.setTag(R.id.child_show, true);
- }else{
- convertView.setTag(R.id.child_show, false);
- }
- return convertView;
- }
在上面的代码中用到了tag,如果是一个好说直接setTag即可,如果有多个又怎么办呢?
setTag还有一个带int类型的重载,但是设置final类型的常量或者写死数字都会出现:The key must be an application-specific resource id 异常:
需要在ids.xml文件中定义一个ID,然后设置在这里!!
原文地址:http://blog.csdn.net/fcly2013/article/details/20554059?utm_source=tuicool
0 0
- Android -- setTag的妙用和The key must be an application-specific resource id 异常
- android setTag的妙用和The key must be an application-specific resource id 异常
- Android解决:View.setTag(key,object)异常:The key must be an application-specific resource id.
- View.setTag(key,object)异常:The key must be an application-specific resource id.
- View.setTag(key,object)异常 The key must be an application-specific resource id.
- View.setTag(key,object)异常:The key must be an application-specific resource id.
- View.setTag(key,object)异常:The key must be an application-specific resource id.
- View.setTag(key,object)异常:The key must be an application-specific resource id.
- setTag使用错误The key must be an application-specific resource id.
- AndroidRuntime: FATAThe key must be an application-specific resource id.
- Android view.setTag的妙用。
- setTag()的妙用!
- Android setTag方法定义key的问题
- Android studio编译错误二:Error: The WIFI_SERVICE must be looked up on the Application
- 【Android】- Error:The<activity>element must be a direct child of the <application> element[WrongMani]
- Android studio编译错误 Error: The WIFI_SERVICE must be looked up on the Application
- Android studio编译错误二:Error: The WIFI_SERVICE must be looked up on the Application
- Main application must be in the list of application paths
- Android—TextView 背景颜色与背景图片设置
- 图片加载框架Picasso解析
- 【我们都爱Paul Hegarty】斯坦福IOS8公开课个人笔记6 init
- ADF笔记
- Java深入 - Java 内存分配和回收机制
- android setTag的妙用和The key must be an application-specific resource id 异常
- Windows下Apache与PHP的安装与配置
- 表示数字
- 贝叶斯学习及共轭先验
- 点击放大图片、滚动缩放图片(无插件,自己写的)
- Erlang的tv、appmon等GUI工具在R17以上版本的启动方法
- Unity ShaderLab学习总结
- Wireshark 显示过滤器样例整理.
- java高效实现随机数的方法