On Fri, Apr 29, 2011 at 8:14 PM, Eric <[email protected]> wrote: > On Apr 29, 3:37 pm, Dianne Hackborn <[email protected]> wrote: > > On Fri, Apr 29, 2011 at 3:20 PM, Eric <[email protected]> wrote: > > Ah. If you are doing an actual data change, the list view needs to > rebuild > > the list at that point, and likely the touch will be lost. You really > don't > > want to be doing a big data update every second for numerous reasons: it > is > > expensive so causes a lot of CPU use, it will result in non-smooth > scrolling > > since all of the views being shown in the list need to be rebuilt each > time, > The same app performs absolutely fine on the iPhone. The Android > version is not performing too badly. This is a realtime trading > application. It needs to update at least once a second. Our iPhone > app updates 2-3 times per second. >
Well I can't speak to how the iPhone works, but I can say that you should not be invalidating your entire data set so often. You can certainly change the data being shown inside of the views as you want -- just set the text of a text view or such -- but invalidating the data set is what tells the list view to rebuild all of its data structures because the entire data set has changed. You can certainly have individuals inside of the list view updating more than once a second. You just need to do it the right way. > if your data is actually changing that much then it will be changing > > continually on the user (including items potentially moving around) which > is > > not a good UX > I don't understand this comment at all. > The API you are using is for when the list view needs to be rebuilt because the underlying data set has changed. This shouldn't be happening often in a list view, it is a significant event, and having that happen in a list view is not going to be a good user experience. Like -- items moving around all the time so you can't trust what you are going to click on. > , and finally since all of the views are being rebuilt the one > > the user is currently touching is likely to be rebuilt and the current > touch > > lost. > How can the touch possibly be lost if both the redraw of the list > view, and the touch, are happening on the main UI thread? > The list view isn't just being redrawn! The API you are using tells it to rebuild its contents. The item the user was touching is no longer the same. > > A list view is definitely not the way to show "real time" data like this. > > If the items *inside* of the list view want to update at a frequent rate > to > > show new data they can certainly do that by just changing their visuals, > but > > you don't want to tell the list view that your data set has changed > because > > then it needs to throw all of its current views away, retrieve the new > data, > > and bind that data to new views. > We can't really do that. Many of the screens in the app show market > depth, and the depth changes update-by-update. You need to redraw the > entire list every time. > This isn't about redrawing the list, this is about not rebuilding the list. For an individual item, just change it and it will redraw (or call invalidate() if it is a custom view doing its own drawing). -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. 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

