[android-developers] Re: List Item (a view) order changes unexpextedly while (fast) scrolling in a ListView
so sorry for late reply, the one that you post is the old one, james.. and, yeah, the problem is still not solved yet, my only solution is to create new view all the time: public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; convertView = mInflater.inflate(R.layout.list_item, null); viewHolder = new ViewHolder(); viewHolder.myView = (MyView) convertView.findViewById(R.id.myview); convertView.setTag(viewHolder); viewHolder.myView.setText(objects[position]); return convertView; } On Sep 8, 3:20 am, jamesc jame...@gmail.com wrote: Hi Sorry, I think I misunderstand you last post. Which of the two methods is the 'old' one (with the 'random order' problem) and which is the 'new' one (where the problem has gone away)? I would assume that the new/correct version is this one?: public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { convertView = mInflater.inflate(R.layout.list_item, null); viewHolder = new ViewHolder(); viewHolder.myView = (MyView) convertView.findViewById(R.id.myview); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.myView.setText(objects[position]); // -- THIS IS THE NEW LINE return convertView; } On Sep 8, 4:18 am, rious.delie rious.de...@gmail.com wrote: Okay, great, you are right, james.. there is something wrong on the getView implementation, still not sure why, but my problem is solved by, something like this: @Override publicViewgetView(int position,ViewconvertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { convertView = mInflater.inflate(R.layout.list_item, null); viewHolder = new ViewHolder(); viewHolder.myView = (MyView) convertView.findViewById(R.id.myview); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.myView.setText(objects[position]); return convertView; } changed to: @Override publicViewgetView(int position,ViewconvertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { convertView = mInflater.inflate(R.layout.list_item, null); viewHolder = new ViewHolder(); viewHolder.myView = (MyView) convertView.findViewById(R.id.myview); viewHolder.myView.setText(objects[position]); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } return convertView; } On Sep 7, 2:03 pm, jamesc jame...@gmail.com wrote: Hi 1) I'm still not sure why you're doing the measuring yourself (as I'd use a layout xml file to declare thelistitem'sView, and then inflate it/set the values in the adapter's getView() call. 2) I'm guessing that since you are using an adapter and theview holder, that there's an issue with how your getView() method is implemented (or perhaps another implementation of an adapter method). That is, as you know theviewholder allows object reuse; that doesn't mean to say that the object that you're re-using has the correct values in it. It's only there to avoid the expensive inflation/ construction; after that point you're expected to set the values in that object (for thelistitem) as per the data in the array/list/ structure that is backing the adapter. On Sep 7, 3:55 am, rious.delie rious.de...@gmail.com wrote: thank you, 1) yes, it is anitemon alistview, i populate some numbers of it on alistview. 2) i need to set the height of theviewon runtime, because the height of theviewis 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 bitmap1changesorderrandomlywhilebitmap2 stays where it should be, something like this: alistview= 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
[android-developers] Re: List Item (a view) order changes unexpextedly while (fast) scrolling in a ListView
Hi Sorry, I think I misunderstand you last post. Which of the two methods is the 'old' one (with the 'random order' problem) and which is the 'new' one (where the problem has gone away)? I would assume that the new/correct version is this one?: public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { convertView = mInflater.inflate(R.layout.list_item, null); viewHolder = new ViewHolder(); viewHolder.myView = (MyView) convertView.findViewById(R.id.myview); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.myView.setText(objects[position]); // -- THIS IS THE NEW LINE return convertView; } On Sep 8, 4:18 am, rious.delie rious.de...@gmail.com wrote: Okay, great, you are right, james.. there is something wrong on the getView implementation, still not sure why, but my problem is solved by, something like this: @Override publicViewgetView(int position,ViewconvertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { convertView = mInflater.inflate(R.layout.list_item, null); viewHolder = new ViewHolder(); viewHolder.myView = (MyView) convertView.findViewById(R.id.myview); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.myView.setText(objects[position]); return convertView; } changed to: @Override publicViewgetView(int position,ViewconvertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { convertView = mInflater.inflate(R.layout.list_item, null); viewHolder = new ViewHolder(); viewHolder.myView = (MyView) convertView.findViewById(R.id.myview); viewHolder.myView.setText(objects[position]); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } return convertView; } On Sep 7, 2:03 pm, jamesc jame...@gmail.com wrote: Hi 1) I'm still not sure why you're doing the measuring yourself (as I'd use a layout xml file to declare thelistitem'sView, and then inflate it/set the values in the adapter's getView() call. 2) I'm guessing that since you are using an adapter and theview holder, that there's an issue with how your getView() method is implemented (or perhaps another implementation of an adapter method). That is, as you know theviewholder allows object reuse; that doesn't mean to say that the object that you're re-using has the correct values in it. It's only there to avoid the expensive inflation/ construction; after that point you're expected to set the values in that object (for thelistitem) as per the data in the array/list/ structure that is backing the adapter. On Sep 7, 3:55 am, rious.delie rious.de...@gmail.com wrote: thank you, 1) yes, it is anitemon alistview, i populate some numbers of it on alistview. 2) i need to set the height of theviewon runtime, because the height of theviewis 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 bitmap1changesorderrandomlywhilebitmap2 stays where it should be, something like this: alistview= 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 theorderof bitmap1changes: 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, theorderrandomchangesappearwhilei scroll
[android-developers] Re: List Item (a view) order changes unexpextedly while (fast) scrolling in a ListView
Hi 1) I'm still not sure why you're doing the measuring yourself (as I'd use a layout xml file to declare the list item's View, and then inflate it/set the values in the adapter's getView() call. 2) I'm guessing that since you are using an adapter and the view holder, that there's an issue with how your getView() method is implemented (or perhaps another implementation of an adapter method). That is, as you know the view holder allows object reuse; that doesn't mean to say that the object that you're re-using has the correct values in it. It's only there to avoid the expensive inflation/ construction; after that point you're expected to set the values in that object (for the list item) as per the data in the array/list/ structure that is backing the adapter. On Sep 7, 3:55 am, rious.delie rious.de...@gmail.com wrote: thank you, 1) yes, it is anitemon alistview, i populate some numbers of it on alistview. 2) i need to set the height of theviewon runtime, because the height of theviewis 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 bitmap1changesorderrandomlywhilebitmap2 stays where it should be, something like this: alistview= 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 theorderof bitmap1changes: 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, theorderrandomchangesappearwhilei scroll thelistview 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 yourView(MyView) is theitemin theListView? 2) Why are you doing the measuring (and implementing onDraw())? I would have thought that you should be using a layout to declare the ListViewitemand then backing that with a BaseAdapter implementation (where you should look at using the viewholder 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: List Item (a view) order changes unexpextedly while (fast) scrolling in a ListView
Okay, great, you are right, james.. there is something wrong on the getView implementation, still not sure why, but my problem is solved by, something like this: @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { convertView = mInflater.inflate(R.layout.list_item, null); viewHolder = new ViewHolder(); viewHolder.myView = (MyView) convertView.findViewById(R.id.myview); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.myView.setText(objects[position]); return convertView; } changed to: @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { convertView = mInflater.inflate(R.layout.list_item, null); viewHolder = new ViewHolder(); viewHolder.myView = (MyView) convertView.findViewById(R.id.myview); viewHolder.myView.setText(objects[position]); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } return convertView; } On Sep 7, 2:03 pm, jamesc jame...@gmail.com wrote: Hi 1) I'm still not sure why you're doing the measuring yourself (as I'd use a layout xml file to declare the list item's View, and then inflate it/set the values in the adapter's getView() call. 2) I'm guessing that since you are using an adapter and the view holder, that there's an issue with how your getView() method is implemented (or perhaps another implementation of an adapter method). That is, as you know the view holder allows object reuse; that doesn't mean to say that the object that you're re-using has the correct values in it. It's only there to avoid the expensive inflation/ construction; after that point you're expected to set the values in that object (for the list item) as per the data in the array/list/ structure that is backing the adapter. On Sep 7, 3:55 am, rious.delie rious.de...@gmail.com wrote: thank you, 1) yes, it is anitemon alistview, i populate some numbers of it on alistview. 2) i need to set the height of theviewon runtime, because the height of theviewis 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 bitmap1changesorderrandomlywhilebitmap2 stays where it should be, something like this: alistview= 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 theorderof bitmap1changes: 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, theorderrandomchangesappearwhilei scroll thelistview 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 yourView(MyView) is theitemin theListView? 2) Why are you doing the measuring (and implementing onDraw())? I would have thought that you should be using a layout to declare the ListViewitemand then backing that with a BaseAdapter implementation (where you should look at using the viewholder 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+unsubscr...@googlegroups.com For more
[android-developers] Re: List Item (a view) order changes unexpextedly while (fast) scrolling in a ListView
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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: List Item (a view) order changes unexpextedly while (fast) scrolling in a ListView
i think i have to try using scrollview instead of listview.. On Sep 7, 9:55 am, rious.delie rious.de...@gmail.com wrote: 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: List Item (a view) order changes unexpextedly while (fast) scrolling in a ListView
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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en