tag:blogger.com,1999:blog-7713297736511326532.post1893344803250881128..comments2016-09-01T20:01:48.933+01:00Comments on SpareTimeDev: Recycling of views with Heterogeneous List AdaptersAndyhttp://www.blogger.com/profile/11474729951114908287noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-7713297736511326532.post-70445856956056339352016-08-29T15:29:24.216+01:002016-08-29T15:29:24.216+01:00I ran into this ClassCastException issue because I...I ran into this ClassCastException issue because I was changing the return value of getViewTypeCount at runtime. Obviously ListView doesn't like this.<br /><br />So its a good idea to always return the maximum number of possible viewTypes, even if not all are used at a specific time.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7713297736511326532.post-36598767223282919922013-10-13T12:24:17.972+01:002013-10-13T12:24:17.972+01:00Thanks to your hint I managed to fix the problem. ...Thanks to your hint I managed to fix the problem. No idea why this fixes it though!<br /><br />mImageViewLayoutParams was type GridView.LayoutParams. Makes sense because that is the type of the parent view right?<br />However although this works fine for the ImageView, it turns out that it causes the strange behaviour observed in this post if you use it for the LinearLayout (same behaviour observed with RelativeLayout).<br /><br />The solution was to change the type of mImageViewLayoutParams to ViewGroup.LayoutParams.<br /><br />I have no idea why this should cause this problem and why this fix works!<br /><br />If anyone can enlighten me I would be very grateful.<br />Andyhttps://www.blogger.com/profile/11474729951114908287noreply@blogger.comtag:blogger.com,1999:blog-7713297736511326532.post-51958091632981489312013-10-12T20:37:49.485+01:002013-10-12T20:37:49.485+01:00Sorry I don't understand what you mean - I am ...Sorry I don't understand what you mean - I am using LayoutInflater as you can see.<br />How can setLayoutParams() affect this issue? <br /><br />Please can you clarify what you mean?Andyhttps://www.blogger.com/profile/11474729951114908287noreply@blogger.comtag:blogger.com,1999:blog-7713297736511326532.post-8440077358935436382013-10-10T02:45:46.823+01:002013-10-10T02:45:46.823+01:00Can you test it if you use LayoutInflater? I think...Can you test it if you use LayoutInflater? I think your LayoutParam creates this bug. I just test it without LayoutParam and they're OK.Anonymoushttps://www.blogger.com/profile/07054792675201489712noreply@blogger.comtag:blogger.com,1999:blog-7713297736511326532.post-503659439075695522013-08-24T20:52:36.258+01:002013-08-24T20:52:36.258+01:00You're a life saver! :D Thank you so much!!! I...You're a life saver! :D Thank you so much!!! I had this problem for a long long time! mmhttps://www.blogger.com/profile/12597204907068276629noreply@blogger.com