注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

姑射道人的博客

博客新地址:nixuchen.com

 
 
 

日志

 
 

Can't have a viewTypeCount < 1  

2014-05-08 21:50:38|  分类: android |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

So I am not sure what you want to do, but understand that getViewTypeCount() is only called once when you call setAdapter on the list view. So if the list is null or empty at that point, your application will fail. The value returned here should be thought of as more of a constant.

ViewTypes are used in View Recycling. Basically by specifying it as the length of the list, you are saying that every entity in the list would not be able to reuse any other view that the others in the list have used. If this is really true then this behavior is fine, but the minimum value has to at all times be 1. Also this cannot change after calling setAdapter until you create a new adapter to be set on the list view with the new content (this is just hot the view recycler in lister adapter works).

I would assume you could get by with a viewtypeCount of 1 since all your objects are of the same type. So just don't override getItemViewType or getItemViewCount(). These default to 0 and 1 respectively which will suffice for the adapter code you posted and still make efficient use of the view recycler.


http://stackoverflow.com/questions/7789696/getting-viewtypecount-1-error-for-list-view-some-times

  评论这张
 
阅读(972)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017