我有問題,我的網格視圖。我想將圖像存儲在表格中,然後在網格視圖中顯示它們。的Android GridView控件與數據庫
// ImageAdapter
String[] strings = db.getPictures();
Integer[] ints = new Integer[strings.length];
for (int i=0; i < strings.length; i++) {
ints[i] = Integer.parseInt(strings[i]);
}
imageView.setImageResource(ints[position]);
return imageView;
//DatabaseHandler
public String[] getPictures(){
int i=0;
String selectQuery = "SELECT pictureName FROM Category";
SQLiteDatabase db = this.getReadableDatabase();
Cursor c = db.rawQuery(selectQuery, null);
int rowsNumber=c.getCount();
String[] mThumbIds;
mThumbIds= new String[rowsNumber];
if (c.moveToFirst()) {
do {
mThumbIds[i]=c.getString(0);
i++;
} while (c.moveToNext());
}
return mThumbIds;
}
而當我運行我的應用程序它開始暗戀。單串我省像R.drawable.ic_work
發表您的logcat的。 –
我猜的錯誤是不** **發現嘗試 –
的Integer.parseInt(「FF0000」,16)資源,你需要解析爲一個十六進制INT – gvmani