Custom view in ListView disappears while scrolling in Android
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.
精彩评论