I have tried to do that - doesn't working for me :(
Animation is running always without last cell.
I think so:
In first case there is a '0' at the end of position values. Without
your algorithm all 100 animations is running, than without last ( and
there is no '0' at the end ).
With you alhorithm animation will start before position will be a '0'
for the third time, because _visited[0] will be true;
I think there is some regularity here.

And one more thing... I would like to start animations in some other
function. Than it's working fine. For example in onCreate method in
the my grid click listener: after mGameGrid.setAdapter(mAdapter). But
I need to set timer in 200, or 500 ms for waiting for getView finish
its work ( but even so, it's not always make it in time and I see only
half or 2/3 of all animations running). If I call start animation
after setAdapter without timer - it's doesn't work. Why animation is
working fine in that case, but don't working if I run it in getView
method, even with your algorithm?

On 28 апр, 16:55, Streets Of Boston <[email protected]> wrote:
> Don't rely on the order in which getView is called. It is not a bug.
> It is a decision of the design of the grid/list view not to be
> dependent on the order in which getView is called. Why getView with
> position '0' is called three times... i don't know. *If* this is a
> bug, it is only a peformance issue. Maybe it has to do with lay-out
> issues (layout 'weights' are used)? Just don't rely on the order.
>
> However, maybe you can do this instead. Below is code that does not
> rely on the number of times getView is called nor the order in which
> it is called:
>
> You know that you have 100 cells. Make an array of 100 booleans as an
> instance variable of your adapter or activity (e.g. boolean[] _visited
> = new boolean[100]). Initially, set every element in this array to
> false. When getView is called with a value of position, do this inside
> of your getView method:
>
>   ...
>   ...
>   _visited[position] = true;
>   boolean allCellsAreShown = true;
>   for (int i = 0; i < _visited.length; i++) {
>     if (!_visited[i]) {
>       allCellsAreShown = false;
>       break;
>     }
>   }
>   if (allCellsAreShown) {
>     ... // start your animation.
>   }
>   ...
>   ...
>
> (you could optimize the above code a bit... but i think you'd get the
> idea :=) ).
>
> On Apr 28, 9:43 am, "[email protected]" <[email protected]> wrote:
>
>
>
> > I have exactly same problem. Why do we have 102 values of position
> > when there is only 100 cells displayed on screen?
> > "position is changed like: 0, 0, 1, 2, 3... 99, 0" - what is the cause
> > of that? Can someone from google team answer?
> > That seems to be a bug, very annoying bug. Answer "It's not a bug" is
> > not answer! How do you generate position?
>
> > On Apr 27, 9:40 pm, Illidane <[email protected]> wrote:
>
> > > There is a way to make GridView without Adapter ( e.g. something
> > > like .addView() method ) ?
>
> > > On 27 апр, 21:38, Illidane <[email protected]> wrote:
>
> > > > My GridView shows all 100 cells on the screen ( all visible at one
> > > > moment )
> > > > and all the animation works fine, and pretty fast ( on all 100
> > > > elements ),
> > > > but than begin problems with last cell.
> > > > Animation not child-view's. Each cell is a imageView with animation on
> > > > it.
>
> > > > On 27 апр, 20:43, Streets Of Boston <[email protected]> wrote:
>
> > > > > It's not buggy. I use the adapters and grid/list-views in my apps and
> > > > > they work fine. I think they are not designed for your purpose.
>
> > > > > e.g. If your adapter has 100 elements and the grid/list-view only
> > > > > shows about 15 at a time on the screen, the getView is called about 15
> > > > > times. Sometimes more times, depending whether a little bit (a few
> > > > > pixels) of the top or bottom child-view become visible or not. Then,
> > > > > when you start scrolling, getView gets called again and again when
> > > > > child-views become visible and others become invisible.
>
> > > > > Also, seriously consider re-using the convertView for your grid- or
> > > > > list-view. My experience is that it can really slow down your app if
> > > > > you just return new View instances for each child-view/cell:
> > > > > public ... getView(....) {
> > > > >   View view = convertView != null ? convertView : createNewView(...);
> > > > >   ...
> > > > >   ...
> > > > >   return view;
>
> > > > > }
>
> > > > > The implementation of the adapter+listviews does not need to rely on
> > > > > the order in which the getView is called. As long as it is called for
> > > > > every child-view that becomes visible.
>
> > > > > Isn't is possible to start a child-view's (cell's) animation when you
> > > > > handle it the getView(...) method?
>
> > > > > If you really want at least 100 child-views/cells to be created (i
> > > > > won't recommend it... it's a LOT), you can override the Adapter's
> > > > > getViewTypeCount() and getItemViewType(int pos). Even with this, I'm
> > > > > still not sure if getView would get called in the order you want.
>
> > > > > ...
> > > > >   private static int EXPECTED_CELL_COUNT = 100;
>
> > > > >   public int getViewTypeCount() { return EXPECTED_CELL_COUNT; }
> > > > >   public int getItemViewType(int pos) { return pos %
> > > > > EXPECTED_CELL_COUNT; }
>
> > > > > On Apr 27, 1:07 pm, Illidane <[email protected]> wrote:
>
> > > > > > And you think it's not a bug? where is guarantee that it will work 
> > > > > > in
> > > > > > general?
> > > > > > Where adapter takes it's magic number N?
>
> > > > > > On 27 апр, 19:56, Romain Guy <[email protected]> wrote:
>
> > > > > > > There is no guarantee it's going to be called N times either.
>
> > > > > > > 2009/4/27 Illidane <[email protected]>:
>
> > > > > > > > Even with convertView problem is still same - last cell is not
> > > > > > > > animating.
> > > > > > > > And... you said WHEN getView()... I think it's no matter, 
> > > > > > > > matter HOW
> > > > > > > > MANY times getView() called.
> > > > > > > > It calls more than 100 times, whats very strange.
> > > > > > > > For the first time it's called 102 times and all animations was
> > > > > > > > working. For the second and next times it was 101, and last 
> > > > > > > > animation
> > > > > > > > was static.
> > > > > > > > I think where is some bug regularity...
>
> > > > > > > > On 27 апр, 19:31, Romain Guy <[email protected]> wrote:
> > > > > > > >> You should ALWAYS reuse the convertView, oherwise you're gonna 
> > > > > > > >> eat up
> > > > > > > >> memory and just slow down your app. And like I said, there is 
> > > > > > > >> no
> > > > > > > >> guarantee on how and when getView() is called so you cannot 
> > > > > > > >> rely on it
> > > > > > > >> with your anim counter.
>
> > > > > > > >> 2009/4/27 Illidane <[email protected]>:
>
> > > > > > > >> > I dont use convertView parametr and return new child-view.
>
> > > > > > > >> > Each cell has an animation. In the getView I generate an 
> > > > > > > >> > array of
> > > > > > > >> > animations, wich I start when the adapter stops his work ( 
> > > > > > > >> > e.g. when
> > > > > > > >> > my mAnimCounter == 102 ( but need be max 100, lol ) When I 
> > > > > > > >> > run app,
> > > > > > > >> > all 100 cells are animated. But when I re-check the field as 
> > > > > > > >> > I need
> > > > > > > >> > and call mGameGrid.setAdapter(mAdapter), new animations 
> > > > > > > >> > working, but
> > > > > > > >> > last. Last cell are NOT animated. Problem can be only in 
> > > > > > > >> > getView and
> > > > > > > >> > method how it works. I very doubt that it's not a bug of 
> > > > > > > >> > GridView or
> > > > > > > >> > Adapter.
>
> > > > > > > >> > On 27 апр, 18:59, Streets Of Boston 
> > > > > > > >> > <[email protected]> wrote:
> > > > > > > >> >> The child/item-views in list-views and grid-views are 
> > > > > > > >> >> re-used
> > > > > > > >> >> (convertView input parameter). I suspect that depending on 
> > > > > > > >> >> the layout/
> > > > > > > >> >> measurements/visibility of the child-views and the way you 
> > > > > > > >> >> implement
> > > > > > > >> >> getView (re-using convertView or ignoring it and returning 
> > > > > > > >> >> a brand-new
> > > > > > > >> >> child-view every time), the order in which these 
> > > > > > > >> >> child-views are
> > > > > > > >> >> called (value of 'position' parameter in the getView 
> > > > > > > >> >> method) can be
> > > > > > > >> >> random.
>
> > > > > > > >> >> On Apr 27, 11:30 am, Illidane <[email protected]> wrote:
>
> > > > > > > >> >> > Why number of getView calls is different??
> > > > > > > >> >> > One time it's 102 ( but need to be 100 ) and the second 
> > > > > > > >> >> > and greater is
> > > > > > > >> >> > 101.
>
> > > > > > > >> >> > On 27 апр, 18:15, Romain Guy <[email protected]> wrote:
>
> > > > > > > >> >> > > It's not a bug. There's no guarantee in the order of 
> > > > > > > >> >> > > the calls wrt to
> > > > > > > >> >> > > the position value. It also depends on how the GridView 
> > > > > > > >> >> > > is
> > > > > > > >> >> > > measured/laid out.
>
> > > > > > > >> >> > > On Mon, Apr 27, 2009 at 6:38 AM, Illidane 
> > > > > > > >> >> > > <[email protected]> wrote:
>
> > > > > > > >> >> > > > Hi,
> > > > > > > >> >> > > > I'm using GridView in my app, and myAdapter ( extends 
> > > > > > > >> >> > > > BaseAdapter) for
> > > > > > > >> >> > > > it. I have overrited method getView(int position, 
> > > > > > > >> >> > > > View convertView,
> > > > > > > >> >> > > > ViewGroup parent) of Adapter and 100 cells in 
> > > > > > > >> >> > > > GridView.
>
> > > > > > > >> >> > > > If I set logger:
> > > > > > > >> >> > > > android.util.Log.w("bla", (new StringBuilder()).append
> > > > > > > >> >> > > > (position).toString()); where is in the getView then 
> > > > > > > >> >> > > > I'll see that
> > > > > > > >> >> > > > position is changed like: 0, 0, 1, 2, 3... 99, 0. 
> > > > > > > >> >> > > > -WTF? ( thats for
> > > > > > > >> >> > > > the first time) and then I call 
> > > > > > > >> >> > > > mGameGrid.setAdapter(mAdapter) and
> > > > > > > >> >> > > > position is going: 0, 0, 1, 2, 3...99.
> > > > > > > >> >> > > > I think it's a bug of BaseAdapter, isn't it?
>
> > > > > > > >> >> > > --
> > > > > > > >> >> > > 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 -
>
> > > > > > > >> --
> > > > > > > >> 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
>
> > > > > > > --
> > > > > > > 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 -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to