samedi 31 octobre 2015

How To load Images from Drawable to SimpleCursorAdapter

I Create a List view with Simple Cursor Adapter in that adapter i fetch my Sqlite Column names now i want to add images to the same adapter from Drawable Folder How can we Do that Give ideas and Sugession thanks..

Here is My Code:

protected void onCreate(Bundle savedInstanceState) {
        int circle[]=new int[]{R.drawable.juice,R.drawable.medicinebowl,R.drawable.kam};
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        listView= (ListView) findViewById(R.id.listView);
 dbHelper = new SqlLiteDbHelper(this);
        try {
            dbHelper.openDataBase();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        sqLiteDatabase = dbHelper.getReadableDatabase();
        cursor = dbHelper.gettitles(sqLiteDatabase);
        String[] from = new String[]{dbHelper.TITLE, String.valueOf(circle)};
int[] to = new int[]{R.id.title,R.id.circle};
        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.title_row, cursor, from, to);
        adapter.notifyDataSetChanged();
        listView.setAdapter(adapter);

Aucun commentaire:

Enregistrer un commentaire