六-调用数据库数据并用RecyclerView使其以列表的形式显示

77 阅读1分钟
        SQLiteDatabase db=SQLiteDatabase.openOrCreateDatabase(ImportDB.DB_PATH + "/" + ImportDB.DB_NAME, null);
        Cursor cursor = db.query(table, null, null, null, null, null, null);
        cursor.moveToFirst();
            do {
                String lesson = cursor.getString(cursor.getColumnIndex("lesson"));
                //String content = cursor.getString(cursor.getColumnIndex("content"));
                //加载到列表
                BookListBean s=new BookListBean(lesson);
                mApplyList.add(s);
                bookListAdapter = new BookListAdapter(mApplyList);
            } while (cursor.moveToNext());

           cursor.close();

###另外 多条数据加载到RecyclerView上却只显示一条

检查对应的Item根布局属性,如果你用了 match_parent, 修改成如下所示:


   android:layout_width="wrap_content"
   android:layout_height="wrap_content"