开发者

Custom view in ListView disappears while scrolling in Android

开发者 https://www.devze.com 2022-12-23 07:32 出处:网络
I wrote a simple custom view for rows in ListView. It works fine, but when I try to scroll the list, I see only white rows without content. And when scrolling is over, rows continue to show again.

I wrote a simple custom view for rows in ListView. It works fine, but when I try to scroll the list, I see only white rows without content. And when scrolling is over, rows continue to show again.

This is how I draw a custom view:

 @Overrid开发者_StackOverflow社区e 
 protected void onDraw(Canvas canvas) { 
      if(poster != null) { 
           canvas.drawBitmap(poster, padding, padding, paint); 
      } 
      canvas.drawText(title, 55 + padding, 16 + padding, paint); 
 }

Maybe I missed something?

P.S. This is short screencast (400kb) http://dl.dropbox.com/u/190203/test.mpeg


Try setting android:cacheColorHint="#00000000" in the XML layout file for the ListView.

Check this- ListView Backgrounds: An Optimization http://developer.android.com/resources/articles/listview-backgrounds.html This can solve your problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消