Thanks! But I think you will get serious performance issues on GridViews and ListViews with many items. In your fix, you cache the View for each possible item. This defeats the purpose of the 'convertView' parameter which has a non-null value when the GridView re-uses a cached View. The amount of Views cached by the GridView is no more than the amount of (partially) visible items on the screen (=ListView.getChildCount()), not the number of possible items (=BaseAdapter.getCount()), which can be much larger.
If you BaseApapter can have many items (more items than can be viewed simultaneously on the screen), you'll likely to hit some serious performance/memory/resource issues. On Feb 24, 1:12 pm, Bolha <[email protected]> wrote: > Hello, guys. > > I've had the same problem and solved it by saving the created views in > an array inside the adapter. Check the chunks of code below: > > public class ImageButtonCanalAdapter extends BaseAdapter { > private Context contexto; > private List<MyClass> list > private View savedViews[]; > > [...] > > public View getView(int position, View convertView, ViewGroup parent) > { > if (convertView == null) { > this.viewsBotoes[position] = new MyView > (this.contexto); > } > > return this.viewsBotoes[position]; > } > > } > > I hope it helps. > > Best regards. > > Bolha > > On 20 jan, 00:35, Streets Of Boston <[email protected]> wrote: > > > > > The animation is not necessary to make it happen. It just makes it > > really easy to actually see the issue :-) > > > On Jan 19, 6:06 pm, Mike M <[email protected]> wrote: > > > > yeah, > > > I get the same on Droid 2.0, Although I get it without having > > > animation applied to the gridview... > > > > I wish there was a uniform / sequential way that getView() was > > > called... > > > > On Jan 18, 5:29 pm, Streets Of Boston <[email protected]> wrote: > > > > > Hi Roman, > > > > > It does happen. :-) > > > > > I can reproduce it almost every time like this: > > > > - Just create an activity with a Grid View with quite a few images (or > > > > grid-items) and attach a grid-layout-animator to the grid-view. > > > > Configure the grid-view-animator in such a way that you see how the > > > > grid-view-items are laid-out. E.g. columns first, rows later. > > > > - Create an (empty) sub-activity that can be launched from the one > > > > having the grid-view. > > > > > - Start your grid-view's activiy in portrait orientation. > > > > - Start your sub-activity. > > > > - Rotate your phone into landscape orientation. > > > > - Press back to finish the sub-activity. > > > > The grid-view's activity is shown again and... > > > > > ... 9 out of 10 times, i see the grid-view being built up in reverse > > > > mode (i'm running on 2.1, Nexus One). > > > > > In my app, the 'getView()' method does not rely on the order in which > > > > the 'getView()' is called at all. > > > > > On Jan 18, 2:15 am, Romain Guy <[email protected]> wrote: > > > > > > I have never noticed such an issue. The only way I can think of that > > > > > would cause this to happen would be if your adapter relies on the > > > > > order of the getView() calls. Note there is absolutely no guarantee > > > > > about the order in which getView() will be called (the position > > > > > argument will not necessarily be sequential, incrementing or > > > > > decrementing.) > > > > > > On Sun, Jan 17, 2010 at 8:57 PM, Mike M <[email protected]> wrote: > > > > > > Streets of Boston, > > > > > > > Thanks for the reply. I do have an animation on my GridView, but I > > > > > > took it off and still notice the problem. > > > > > > > Any ideas? > > > > > > > Thanks > > > > > > > On Jan 17, 1:23 pm, Streets Of Boston <[email protected]> > > > > > > wrote: > > > > > >> I've seen this too in my app. > > > > > > >> If you add a layout-animation, that animates the grid-view children > > > > > >> (i.e. the grid-items), you can clearly see this reverse order. > > > > > > >> On Jan 17, 4:03 am, Mike M <[email protected]> wrote: > > > > > > >> > Hey everyone, > > > > > > >> > I have a gridview of images that I load from the internet. When > > > > > >> > the > > > > > >> > phone rotates (or some other config change), > > > > > >> > onConfigurationChanged() > > > > > >> > is called. When that happens, the items in the gridview are > > > > > >> > reversed > > > > > >> > (meaning, the 1st image is the last; they are in reverse order). > > > > > > >> > Does anyone know why this is or how to change it? I'm hoping > > > > > >> > someone > > > > > >> > has run into this before... > > > > > > >> > Sorry if I don't share any code. I don't think It'd help; it's > > > > > >> > more > > > > > >> > of a conceptual question. > > > > > > >> > Thanks, > > > > > > >> > Mike > > > > > > > -- > > > > > > You received this message because you are subscribed to the Google > > > > > > Groups "Android Developers" group. > > > > > > To post to this group, send email to > > > > > > [email protected] > > > > > > To unsubscribe from this group, send email to > > > > > > [email protected] > > > > > > For more options, visit this group at > > > > > >http://groups.google.com/group/android-developers?hl=en > > > > > > -- > > > > > Romain Guy > > > > > Android framework engineer > > > > > [email protected] > > > > > > Note: please don't send private questions to me, as I don't have time > > > > > to provide private support. All such questions should be posted on > > > > > public forums, where I and others can see and answer them- Hide > > > > > quoted text - > > > > > > - Show quoted text -- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

