【发布时间】:2015-09-15 03:22:16
【问题描述】:
我有一个 RecyclerView 并且在适配器中我需要从我的 sqLite 数据库中获取一个值。更确切地说:
@Override
public void onBindViewHolder(SimpleViewHolder holder, int position) {
shOperations = new ShortcutsOperations(DrawerActivity.instance);
shOperations.open();
List values = shOperations.getAllShortcuts();
try {
icon = DrawerActivity.instance.getPackageManager().getApplicationIcon(name.get(position));
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
holder.title.setImageDrawable(icon);
final View itemView = holder.itemView;
}
"name" 这是我需要的。我的数据库只有 2 列,一列称为 ID,另一列称为 NAME。如何从适配器中的数据库中检索正确的值以正确设置ImageView 中的图像?
【问题讨论】:
-
你的 SQLite 上有这个
name吗?
标签: java android sqlite android-adapter android-recyclerview