【发布时间】:2018-02-01 13:13:46
【问题描述】:
我想制作一个应用程序,我想使用 sqlite 数据库从数组中提取数据,下面给出了数组的示例,有两个字符串和一个图像....数组中有很多项,我想要使用回收站视图以列表形式显示。
帮我看看我该怎么做。
这是我的代码:
public class NotificationAdapter extends RecyclerView.Adapter<NotificationDetailsHolder> {
private List<NotificationHolder> notificationHolderList;
public NotificationAdapter() {
notificationHolderList = new ArrayList<>();
notificationHolderList.add(new NotificationHolder("Name", "Details",R.drawable.image)
));
}
@Override
public NotificationDetailsHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Context context = parent.getContext();
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view=inflater.inflate(R.layout.abc_layout_workshop,parent,false);
return new NotificationDetailsHolder(view);
}
@Override
public void onBindViewHolder(NotificationDetailsHolder holder, int position) {
NotificationHolder notificationHolder = notificationHolderList.get(position);
holder.bindData(notificationHolder);
}
@Override
public int getItemCount() {
return notificationHolderList.size();
}
}
【问题讨论】:
标签: android sqlite android-recyclerview sqliteopenhelper