I'm doing an Android application where I have to display in the listview records from my database. However, the photos I have called the drawables and assigned it to array. How can I display the photos on the ImageView using a SimpleCursorAdapter?
Here's what I have tried so far:
static final int[] imgs = { R.drawable.dinaretreat, // 0 R.drawable.cobterrace, // 1 R.drawable.ventassostreet, // 2 R.drawable.summerhillblvddrouin, // 3 R.drawable.todmanstreetdrouin, // 4 R.drawable.aqueductroad // 5 }; private DBHelper dbHelper; SimpleCursorAdapter dataAdapter; Cursor cursor; Button back, filter; TextView highest, lowest, location; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.viewhouseandland); initControls(); displayRecords(); } private void displayRecords() { // TODO displayRecords // TODO CheckDBConnection checkDatabaseConnection(); // TODO cursor = dbHelper.getAllHouses(); // The desired columns to be bound String[] columns = new String[] { DBHelper.KEY_HOUSE, DBHelper.KEY_PRICE }; // the XML defined views which the data will be bound to int[] to = new int[] { R.id.image, R.id.text1, R.id.text2 }; // create the adapter using the cursor pointing to the desired data //as well as the layout information dataAdapter = new SimpleCursorAdapter( this, R.layout.listrow, cursor, columns, to, 0); lv.setAdapter(dataAdapter); } I'm having a hard time how to display the images on my listview. Any ideas? I'd gladly appreciate your help. Thanks.