Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to improve the scroll speed of my listview
    primarykey
    data
    text
    <blockquote> <p><strong>Edit:</strong> Ok, i took the advice given in the answers and the difference is <strong>huge!</strong> I've replaced my SeriesAdapter in the post with the new one. For one a know make the calculations with in the sql query (to know total number of episodes and totalt numer of watched episodes). I also store the bitmap in a hashmap once it has been loaded so that it don't have to load twice, I'm looking in to some other solution as I'm afraid of OutOfMemoryException.</p> </blockquote> <p>I am new to android and i want to display an listview with images that i have stored on the external storage. </p> <p>The images are downloaded earlier and are now as I said stored in the external storage, here is an example of the images <a href="http://thetvdb.com/banners/graphical/80348-g32.jpg" rel="nofollow">http://thetvdb.com/banners/graphical/80348-g32.jpg</a> and I compress the images to 80% when saving them to save some space.</p> <p>I have tried several methods to make the listview scroll smooth but I'm clearly in over my head here. I have provided my layout for the list items and my adapter in case I do something strange here.</p> <p>I would appreciate any tips and tricks that would improve my listview.</p> <p>SeriesAdapter:</p> <pre><code>public static class SeriesAdapter extends ArrayAdapter&lt;Series&gt; { static class viewHolder { ImageView image; TextView information; String seriesId; String season; ProgressBar progress; TextView txtSmallView; } private final Context context; private final ArrayList&lt;Series&gt; series; private DateHelper dateHelper; private final DatabaseHandler db; Object mActionMode; int resource; public SeriesAdapter(Context context, int resource, ListView lv, ArrayList&lt;ExtendedSeries&gt; objects) { super(context, resource, objects); this.context = context; this.series = objects; this.resource = resource; db = new DatabaseHandler(context); dateHelper = new DateHelper(); cache = new HashMap&lt;String, Bitmap&gt;(); } @Override public View getView(int position, View convertView, ViewGroup parent) { viewHolder holder; ExtendedSeries s = series.get(position); if(convertView == null) { convertView = View.inflate(context, resource, null); holder = new viewHolder(); holder.image = (ImageView)convertView.findViewById(R.id.imgSeriesImage); holder.information = (TextView)convertView.findViewById(R.id.txtUpcomingEpisode); holder.progress = (ProgressBar)convertView.findViewById(R.id.pgrWatched); convertView.setTag(holder); } else { holder = (viewHolder)convertView.getTag(); } if(s != null) { holder.seriesId = s.getImage(); convertView.setTag(R.string.homeactivity_tag_id,s.getID()); convertView.setTag(R.string.homeactivity_tag_seriesid,s.getSeriesId()); holder.progress.setMax(s.getTotalEpisodes()); holder.progress.setProgress(s.getWatchedEpisodes()); holder.image.setImageBitmap(getBitmapFromCache(s.getImage())); holder.information.setText(s.getNextEpisodeInformation().equals("") ? context.getText(R.string.message_show_ended) : s.getNextEpisodeInformation()); } return convertView; } </code></pre> <p>Listitem layout</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" &gt; &lt;ImageView android:id="@+id/imgSeriesImage" android:layout_width="fill_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:focusable="false" android:scaleType="centerCrop" android:src="@drawable/noimage" /&gt; &lt;RelativeLayout android:id="@+id/relProgressView" android:layout_width="match_parent" android:layout_height="wrap_content" android:focusable="false" android:orientation="vertical" &gt; &lt;ProgressBar android:id="@+id/pgrWatched" style="?android:attr/progressBarStyleHorizontal" android:layout_width="fill_parent" android:layout_height="21dp" android:max="100" android:progress="50" android:progressDrawable="@drawable/progressbar" /&gt; &lt;TextView android:id="@+id/txtUpcomingEpisode" android:layout_width="match_parent" android:layout_height="wrap_content" android:focusable="false" android:padding="3dp" android:scrollHorizontally="true" android:scrollbars="none" android:shadowColor="@android:color/black" android:shadowDx="1" android:shadowDy="1" android:shadowRadius="1" android:textAllCaps="true" android:textColor="#ffffffff" android:textSize="11sp" android:textStyle="normal|bold" android:typeface="normal" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p></p> <p>Activity layout</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;ListView android:id="@+id/lstMySeries" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:longClickable="true" android:divider="#000000" /&gt; </code></pre> <p></p>
    singulars
    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.
 

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