Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From the documentation of <a href="http://developer.android.com/reference/android/widget/ImageView.html#setImageResource%28int%29" rel="nofollow">setImageResource()</a>. (emphasize is mine)</p> <blockquote> <p>This does Bitmap reading and decoding on the <strong>UI thread</strong>, which can cause a <strong>latency hiccup</strong>. If that's a concern, consider using setImageDrawable(android.graphics.drawable.Drawable) or setImageBitmap(android.graphics.Bitmap) and BitmapFactory instead.</p> </blockquote> <p>I strongly suggest you to use <a href="http://square.github.io/picasso/" rel="nofollow">Picasso</a> library for showing images. After adding library to your project call following function in <code>getView()</code>:</p> <pre><code>Picasso.with(context).load(item.getDrawable()).into(picture); </code></pre> <p>and thats it.</p> <hr> <pre><code>public class ImageAdapter extends BaseAdapter { private List&lt;Item&gt; items = new ArrayList&lt;Item&gt;(); private LayoutInflater inflater; private Context context; public ImageAdapter(Context context, List&lt;Item&gt; items) { inflater = LayoutInflater.from(context); this.items = items; this.context = context; } . . . @Override public View getView(int i, View view, ViewGroup viewGroup) { View v = view; ImageView picture; TextView name; if (v == null) { v = inflater.inflate(R.layout.squareimageview, viewGroup, false); v.setTag(R.id.picture, v.findViewById(R.id.picture)); v.setTag(R.id.text, v.findViewById(R.id.text)); } picture = (ImageView) v.getTag(R.id.picture); name = (TextView) v.getTag(R.id.text); Item item = (Item) items.get(i); Picasso.with(context).load(item.getDrawable()).into(picture); name.setText(item.name); return v; } } </code></pre>
    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