Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to display actual image based on file name in sqlite database
    primarykey
    data
    text
    <p>I have a local sqlite database file that looks something like this…</p> <pre><code>_ID | Color_Name | Image_Name 1 | Red | red.png 2 | Blue | blue.png 3 | Green | green.png Etc. </code></pre> <p>The Image_Name column of the database contains ONLY the file name, NOT the image itself. All images are stored locally in the res/drawable-mdpi directory.</p> <p>The goal is to have a list that displays the color name and the associated image for that color from the database. For example, the list would look something like this [the plus sign below represents an actual .png image]…</p> <pre><code>____________________________________________ Red (text only on this line) + (actual red.png image on this line) ____________________________________________ Blue (text only on this line) + (actual blue.png image on this line) ____________________________________________ Etc. </code></pre> <p>I can get the color name to display, but I can't figure out how to get the image itself to display. The relevant portion of code for displaying the name is below…</p> <pre><code>static class ColorHolder { private TextView name=null; ColorHolder(View row) { name=(TextView)row.findViewById(R.id.colorName); } void populateFrom(Cursor c, ColortHelper r) { name.setText(r.getName(c)) ; } } </code></pre> <p>The relevant portion of the xml file for BOTH the name &amp; image is below…</p> <pre><code>&lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|left" android:id="@+id/colorName"/&gt; &lt;ImageView android:id="@+id/ImageView00" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/image1" &lt;!--[NOTE: THIS DEFAULT IMAGE FILE SHOULD BE REPLACED ON THE FLY W/THE CORRECT IMAGE FILE FOR EACH RECORD]--&gt; &gt; </code></pre> <p>None of the other questions I found were helpful in resolving this issue for me. Could someone please help me get this figured out? I would be happy for any help, but it would be especially helpful if you could use my ACTUAL file names / paths / variables / ID's / etc. (which are given above) in your explanation so that I could most easily follow &amp; understand your response. Pointing me to tutorials may not be helpful as I have already looked at a lot of material but didn't get this resolved. Thanks!</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.
 

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