Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The crux of the video that @Sam recommended is that you are inflating your views every time you scroll rather than using the <code>recycler</code> built into <code>ListView</code>. You're trying to speed things up by using an <code>Array</code> of <code>RelativeLayout</code>s, but a much better way to do this is to create a <code>ViewHolder</code> for your view so that it can be reused. The <code>ViewHolder</code> is a static inner class. Define it like so:</p> <pre><code>public static class ViewHolder { public TextView currentRatingText; public TextView countryName; public GradientTextView rating; public TextView rank; ... </code></pre> <p>}</p> <p>Then define your inflater in the constructor of your custom adapter like so: <code>rowInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);</code></p> <p>Then, your <code>getView()</code> method should look something like this.</p> <pre><code>public View getView(int pos, View convertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { viewHolder = new ViewHolder; convertView = rowInflater.inflate(context,R.layout.team_ranking_list_item, null); viewHolder.currentRatingText = (TextView) convertView.findViewById(R.id.Rating); viewHolder.countryName = (TextView) convertView.findViewById(R.id.TeamNameTextView); viewHolder.rating = (GradientTextView) convertView.findViewById(R.id.RatingTextView); viewHolder.rank =(TextView) convertView.findViewById(R.id.RankTextView); ... //Views can hold a tag, which is an object. By setting the viewHolder as the //view tag, we can grab it next time so we don't need to re-inflate everything. convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder)convertView.getTag(); } //Here is where you set all of you views' data. T t = arr.get(pos); viewHolder.currentRatingText.setText(t.getText()); viewHolder.countryName.setText("UAE"); ... return convertView; </code></pre> <p>}</p> <p><code>ConvertView</code> is the view that left the screen and can now be reused for the new view on the bottom of the screen. As suggested above, caching images would definitely help, but I think this is enough to get the list scrolling smoothly.</p> <p>The video is still mandatory viewing; Romain Guy is the boss. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload