Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>From the docs for <a href="http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html#setViewImage%28android.widget.ImageView,%20java.lang.String%29" rel="nofollow">SimpleCursorAdapter</a>...</p> <blockquote> <p>Binding occurs in two phases. First, if a SimpleCursorAdapter.ViewBinder is available, setViewValue(android.view.View, android.database.Cursor, int) is invoked. If the returned value is true, binding has occured. If the returned value is false and the view to bind is a TextView, setViewText(TextView, String) is invoked. <strong>If the returned value is false and the view to bind is an ImageView, setViewImage(ImageView, String) is invoked.</strong></p> </blockquote> <p>From the docs for <a href="http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html#setViewImage%28android.widget.ImageView,%20java.lang.String%29" rel="nofollow">SimpleCursorAdapter.setViewImage (ImageView v, String value)</a>...</p> <blockquote> <p>By default, the value will be treated as an image resource. <strong>If the value cannot be used as an image resource, the value is used as an image Uri.</strong></p> </blockquote> <p>So basically if you make it so the <code>KEY_COLOR</code> column of your DB contains <code>Uri</code>s to your images and replace <code>R.id.text_color</code> in your <code>to</code> array with the resource id of an ImageView, in theory your <code>SimpleCursorAdapter</code> will automatically fill the <code>ImageView</code> with the image resolved from the <code>Uri</code>.</p> <p>Never tried it myself but it seems like how it should work.</p> <p><strong>EDIT</strong> See this example of how to use an image with a textview in list rows...<a href="http://whyandroid.com/android/182-fancy-listviews-part-one.html" rel="nofollow">Fancy ListViews Part One</a>. It's written by Mark Murphy aka CommonsWare here on SO. It actually uses a different method to what I was suggesting with a view binder and uses the <code>getView(...)</code> method to set images and text for each row.</p>
 

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