简体   繁体   中英

Listview jumps to the bottom on scrolling fast

So as the title says , i have this problem with my listview . Im not using any ordinary listview , im using the observable scrollview library which is based on a listview .

Firstly, i would like to clarify a few things to give you guys more clarity.

  1. I didn't have this problem until i changed a couple of things with my listview's custom adapters layout.

  2. This seems wierd because i didn't get this problem before .

  3. It scrolls at an abnormal rate , i just fling and it hits the bottom suddenly.

  4. scrolling slowly doesn't cause the problem

  5. Should i slow down my listview and try , if so how ?

  6. I load more items on scroll , i have a footerview too and the footerview stays only a second or less .

This can also be caused by a bug in Android 5.1. The bug report can be found here . Two fast up swipes on a ListView cause it to hit the top of the list and then instantly scroll to the bottom.

Currently the only solution appears to be using a ScrollView instead of a ListView.

In your getView method, you have

inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View v = inflater.inflate(R.layout.custom, parent, false);

Replace with

if (convertView == null) {
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.custom, parent, false);
}

And, it will be much better.

Btw, ViewHolder is not so hard . If this does not work, you have to implement ViewHolder correctly. Also avoid doing too much stuff in getView and make sure you load images asynchronously ( most imageLoader libraries will do this for you )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM