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.

9 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