Monday, September 6, 2010

[android-developers] Re: List Item (a view) order changes unexpextedly while (fast) scrolling in a ListView

thank you,

1) yes, it is an item on a listview, i populate some numbers of it on
a listview.
2) i need to set the height of the view on runtime, because the height
of the view is the variable of width (height = f(width)),
it is just as simple as the TextView, which can determine how many
lines needed to show the text based on a function of display width,
each font width, and the text to be displayed.
Yes, i have implemented an adapter (an extends of ArrayAdapter) and
have used ViewHolder (static class ViewHolder()),

my point is, why bitmap1 changes order randomly while bitmap2 stays
where it should be,

something like this:

a list view =

view1 = bitmap1 = "hai i am bitmap1 in view1"
bitmap2 = "hai i am bitmap2 in view1"

view2 = bitmap1 = "hai i am bitmap1 in view2"
bitmap2 = "hai i am bitmap2 in view2"

view3 = bitmap1 = "hai i am bitmap1 in view3"
bitmap2 = "hai i am bitmap2 in view3"

view4 = bitmap1 = "hai i am bitmap1 in view4"
bitmap2 = "hai i am bitmap2 in view4"

view5 = bitmap1 = "hai i am bitmap1 in view5"
bitmap2 = "hai i am bitmap2 in view5"

i scroll fastly, then the order of bitmap1 changes:

view1 = bitmap1 = "hai i am bitmap1 in view4"
bitmap2 = "hai i am bitmap2 in view1"

view2 = bitmap1 = "hai i am bitmap1 in view5"
bitmap2 = "hai i am bitmap2 in view2"

view3 = bitmap1 = "hai i am bitmap1 in view2"
bitmap2 = "hai i am bitmap2 in view3"

view4 = bitmap1 = "hai i am bitmap1 in view1"
bitmap2 = "hai i am bitmap2 in view4"

view5 = bitmap1 = "hai i am bitmap1 in view3"
bitmap2 = "hai i am bitmap2 in view5"

moreover, the order random changes appear while i scroll the listview
fastly, if i gently scroll it slowly the problem is not occured, it
seems that the problem is not on the code, (is it a bug on android
platform?)


On Sep 6, 2:17 pm, jamesc <jame...@gmail.com> wrote:
> OK.  I've had a quick look.
>
> 1) I take it that your View (MyView) is the item in the ListView?
> 2) Why are you doing the measuring (and implementing onDraw())?  I
> would have thought that you should be using a layout to declare the
> ListView item and then backing that with a BaseAdapter implementation
> (where you should look at using the "view holder" pattern to allow re-
> use of inflated objects.
>
> On Sep 6, 5:15 am, "rious.delie" <rious.de...@gmail.com> wrote:
>
> > somebody please...

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment