How to make ListView super fast

This might be the most asked question. How a listview can be made faster/smoother is really all about optimizations of the code.



You should probably always use a Holder class not to findViewById in every getView call. According to a google IO thingy, this would slightly increase the performance of your ListView.

Of course, do not forget to use the logic: if(convertView == null) then (convertView = new InflatedView). Then intialise everything in convertView... bla bla bla.

However, today I got a +1 on one of my answers on stackoverflow. I gave away a small hack.
@Override
public long getItemViewType(int position) {
     return position;
}
@Override
public long getViewTypeCount(int position) {
     return getCount();
}
@Override
public View getView(int position, View convertView, ViewGroup arg2) {
    if (convertView == null) {
        //inflate your convertView and set everything
    }
    //do not do anything just return the convertView
    return convertView;
}

I found out that I had a small typo: I fixed that. Anyway, I would like to give this away and it would really be nice to tell me if this does not work with you.
The hack is simple: I give each view its own view type, and, therefore, I force the ListView to do the whole caching on its own.

22 comments:

  1. this is shushCrappy code. :p

    ReplyDelete
    Replies
    1. I think I know who is this shushpicious body that commented.

      Delete
  2. The best way to protect your expensive smartphone is by using a case.
    It not only protects your phone from damage due to accidental drop, but also imparts beauty to your phone.
    Here are some of the best and exclusive cases for you.
    You can check them out and select one for your phone Galaxy S8 TPU Cases

    ReplyDelete
  3. Best Android phones are as good as the other Smartphones on the market. oukitelcentral

    ReplyDelete
  4. At the point when the engineers make custom UI interfaces in their own particular manner, the applications don't look or capacity reliably crosswise over various gadgets. from this source

    ReplyDelete
  5. I simply could not depart your web site prior to suggesting that I extremely enjoyed the standard info a person provide on your guests? Is going to be again often in order to check out new posts

    androsupport.com


    ReplyDelete
  6. Exceptionally helpful post. This is my first time i visit here. I discovered such a variety of fascinating stuff in your web journal particularly its exchange. Truly its extraordinary article. Keep it up. App Valley

    ReplyDelete
  7. Features Of Gamecih Download Steps To Install GameCIH APK.

    ReplyDelete
  8. Thank you for posting such a great article! I found your website perfect for my needs
    Read More

    ReplyDelete
  9. Read the information you share, it is very helpful for me. Hope I will learn more interesting information on your blog.
    Dịch vụ: vận chuyển ô tô giá rẻ, dịch vụ bốc xếp, dịch vụ ship cod, vận chuyển xe máy bắc nam, cho thuê xe tải, vận chuyển container,... Đang được proship cung cấp tới quý khách hàng với chất lượng uy tín, giá cả canh tranh nhất thị trường hiện nay.

    ReplyDelete


  10. Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well.
    I wanted to thank you for this websites! Thanks for sharing. Great websites!
    thop tv
    GBWhatsApp APK
    FMWhatsApp APK
    Blackmart APK
    Ac Market APK
    TutuApp APK

    ReplyDelete
  11. Attend The Data Analytics Course From ExcelR. Practical Data Analytics Course Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Data Analytics Course.
    ExcelR Data Analytics Course

    ReplyDelete
  12. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.
    ExcelR data analytics courses

    ReplyDelete

  13. Best Article buy Pain Pills online Excellent post. I appreciate this site. Stick with it! Because the admin of this web page is working, no doubt very quickly it will be well-known, due to its quality contents.This website was how do you say it? Relevant!! Finally, I’ve found something that helped me.
    Best Article buy Roxicodone online Excellent post
    buy Xanax online
    buy Oxycodone online

    Best Article buy Pain Medications online Excellent post. I appreciate this site. Stick with it! Because the admin of this web page is working, no doubt very quickly it will be well-known, due to its quality contents.This website was how do you say it? Relevant!! Finally, I’ve found something that helped me.

    buy Research Chemicals online

    buy Roxicodone online

    buy Cbd Isolate online

    ReplyDelete
  14. Great job in giving the right content the reasonable clarification. The substance looks genuine with substantial data. Great Work

    ReplyDelete