I am from the Google team (and I did implement a lot of GridView and ListView) and it is NOT a bug. GridView and ListView can call getView() out of order and more times than the number of views that will fit on screen, depending how the Grid/ListView is measured/laid out.
2009/4/28 [email protected] <[email protected]>: > > 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 - > > > -- 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 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

