Improving scroll smoothness in Android ListView

I have an Android ListView that has a small (say 1-5 frames) stutters when it scrolls about every second or so. I understand that many Android phones have problems with the smoothness of the animation, but on my phone (Motorola A855 running Android 2.2) my own contact list scrolls pretty smoothly. Viewing a position in a contact list is more complicated than representing an item in my list:

 <RelativeLayout> <TextView /> <TextView /> </RelativeLayout> 

I just want to achieve smoothness as good as my native contact list. It seems that this should be possible without optimization in the native code, but maybe I'm wrong.

I tried several things: I simplified the presentation of the element even more, and I tried to create it programmatically instead of XML. I also tried to change the way we respond to events when an element clicks on this link:

http://groups.google.com/group/android-developers/browse_thread/thread/7dc261a6b382ea74?pli=1

None of this affects performance.

Is there anything I can do in my application to improve performance? I am looking to deploy this application on multiple phones, so changing the settings on the phone or rooting the device in my case is not an option. Here is the getView method from my adapter class:

  public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater flater = (LayoutInflater)context.getSystemService(ListActivity.LAYOUT_INFLATER_SERVICE); layout = flater.inflate(R.layout.song_view, parent, false); TextView first = (TextView)layout.findViewById(R.id.firstLine); TextView second = (TextView)layout.findViewById(R.id.secondLine); Thing t = array.get(position); first.setText(t.title); second.setText(t.name); return layout; } 

Thanks in advance!

+8
android android-listview smooth-scrolling
source share
2 answers

It's hard to see why this could happen without your code.

However, one place to look is your getView () method in your ListAdapter (assuming you are using a custom adapter). Try reusing the view that is passed as an argument to this method, rather than creating a new one each time. Also, do not do anything too heavy with this method (for example, a network call), in fact, try to make it as lean and medium-sized as possible to provide the best performance.

+6
source share

You tried to use the effective adapter http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List14.html

From my point of view, the problem of smoothness of the animation is due to the fact that the garbage collector is running in the background. If you create many objects, you will see a lag in the scrolling list.

I hope for this help.

+3
source share

All Articles