Hi, Streets Of Boston.

I haven't thought about that, maybe because my GridView shows very few
elements (like 10 or 20).
Although seeing the getView method passing or not an instantiated
view, I didn't realize that it was caching just the visible views.

But how can we fix the sorting problem without doing a manual views
caching? I've seen that the position parameters is informed in order,
but I have no clue why the View instance doens't correspond to the
correct position.
Oh, just to make it clear, I'm programming on SDK version 2.1 but
running on a 1.5 device.

Thanks for the help


Bolha

On 24 fev, 17:40, Streets Of Boston <flyingdutc...@gmail.com> wrote:
> 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<lucasros...@gmail.com> 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 <flyingdutc...@gmail.com> 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 <mike.mos...@gmail.com> 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 <flyingdutc...@gmail.com> 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 <romain...@android.com> 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 <mike.mos...@gmail.com> 
> > > > > > 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 <flyingdutc...@gmail.com> 
> > > > > > > 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 <mike.mos...@gmail.com> 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 
> > > > > > > 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
>
> > > > > > --
> > > > > > Romain Guy
> > > > > > Android framework engineer
> > > > > > romain...@android.com
>
> > > > > > 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 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

Reply via email to