Making ListView Scrolling Smooth


介绍了主要的2种方法优化listview:

一,使用线程处理文件操作,网络处理和sql语句,尽量只在main thread中处理和ui相关的操作

         1, AsyncTask automatically queues up all the execute() requests and performs them serially. 

        以队列的方式处理所有请求

    2,Beginning with Android 3.0 (API level 11), an extra feature is available in AsyncTask so you can enable it to run across multiple processor cores. Instead of calling execute() you can specify executeOnExecutor() and multiple requests can be executed at the same time depending on the number of cores available.

       在3.0以上的系统中,可以使用executeOnExecutor()同时处理多个请求,具体请求个数决定于有几个cpu;


二,使用View Holder

        listview在滑动过程,item会创建和回收;  而使用findViewById()很消耗时间,所以采用view holder来代替findViewById()减少时间的消耗,进而提高listview滑动效率;

     

你可能感兴趣的:(Making ListView Scrolling Smooth)