elmorabea
elmorabea

Reputation: 3263

Handling heavy processing within getView() method of a custom list adapter

My problem is simply that i have a custom ListView with custom Adapter .. in the Adapter getView() method i need some heavy processing to deduce the actual UI values ?

Which is making the scrolling horrible .. i'm using all the guide lines

Using recycled views .. Using ViewHolder design pattern

This processing isn't network operations or data retrieving they're just some loops and stuff How do i stop it from ruining my scrolling smoothness ?

Not sure if threading can be an answer since the UI values and handling are depending on the outcome of that processing ..

EDIT I've taken care of the processing problem .. it's done in background now .. My problem now is the listeners .. I've an EditText and Spinner .. and they are initialized to a value rather than the default

the Listeners are firing too often that they're screwing with the scrolling ..

Upvotes: 0

Views: 339

Answers (1)

James Zhao
James Zhao

Reputation: 418

First, you should never do heavy processing in UI thread method. Unfortunately, getView() is a typically UI thread method.

Second, use worker thread to do heavy processing, then refresh your item view when the processing is done.

Third, if you want to improve the scrolling performance further, stop refreshing UI when fling.

Upvotes: 1

Related Questions