【发布时间】:2021-04-13 16:22:19
【问题描述】:
我已经在我的数据库中存储了一些图片中的链接以及文本到它,其中:
int drawableID = context.getResources().getIdentifier("devil", "drawable", getPackageName());
iv.setImageResource(drawableID);
String info = String.valueOf(drawableID);
mDbHelper.open();
mDbHelper.createSmiley("You received a satanic message", info);
mDbHelper.close();
现在我在我的布局中定义了一个网格视图,如下所示:
<GridView
android:layout_height="175dp"
android:layout_width="fill_parent"
android:gravity="bottom|right"
android:numColumns="5"
>
</GridView>
现在我想从我的数据库中导入我的图片,它们显示在我的 GridView 中并且我可以选择其中一张。但我不明白这是如何工作的,我怎么能意识到这一点?这是我导入所有数据库条目的方法:
public Cursor getAllSmileys() {
return this.mDb.query(DATABASE_TABLE, new String[] { ROW_ID,
SOURCE, INFO }, null, null, null, null, null);
}
所以我的问题是如何将所有这些图片导入到我的网格视图中以显示它们?我也希望用户可以选择其中之一。
【问题讨论】: