0

I have a listview with 2 textviews inside of it that are filled by a database using the simple cursor adapter. I want to add an image inside each item in the list with the corresponding image from the database. I have searched around about this topic but have yet to find a solution. any help would be greatly appreciated

String[] from = new String[]{InventoryDbAdapter.KEY_TITLE, InventoryDbAdapter.KEY_DESCRIPTION};

    // and an array of the fields we want to bind those fields to (in this case just text1)
    int[] to = new int[]{R.id.text1,R.id.text2};

    // Now create a simple cursor adapter and set it to display
    SimpleCursorAdapter inventory = 
        new SimpleCursorAdapter(this, R.layout.row, InventoryCursor, from, to);
    setListAdapter(inventory

thanks

waa1990
  • 2,365
  • 9
  • 27
  • 33

1 Answers1

0

Really? Because a quick Google search turned up this blog entry which I think is the same one I used for my Android applications.

Andrew White
  • 52,720
  • 19
  • 113
  • 137
  • I have seen that tutorial before but I dont see how that tutorial relates to a database it is just adding things to an array list – waa1990 Mar 13 '11 at 05:27
  • That's not clear from your questions at all. It's titled "how do I add an image to my listview in android?" (no mention of a database really); You normally don't store images in a db but rather their paths and the images go in an asset directory which can then be accessed and used as the above tutorials explains. – Andrew White Mar 13 '11 at 05:37
  • I did only store their paths in the database I guess i do not have enough experience with listiews to fully understand that tutorial. – waa1990 Mar 13 '11 at 05:39
  • just go through the tutorial fully and when you get stuck ask a more specific question. – Andrew White Mar 13 '11 at 05:44
  • ok I guess the part I am not understanding is in the method getorders(), when the items are added to the array list there are only 2 items but with my database I have no idea how many there would be so how would i make this more dynamic in order to use text and images of an unknown amount? – waa1990 Mar 13 '11 at 05:53