我正在使用 AndroidPaging
库从我的RecyclerView
. 我能够正确查看数据,但是当我打印列表的大小时,它返回零。
以下是我的代码:
val itemViewModel =
ViewModelProviders.of(this, MyViewModelFacotry(disciplineId, schoolId, yearId)).get(StudentInfoViewModel::class.java)
activity?.let {
itemViewModel.itemPagedList.observe(it, Observer<PagedList<StudentData>> { studentDataPagedList ->
if(BuildConfig.DEBUG){
Log.i("MainActivity",studentDataPagedList?.size.toString())
}
studentInfoNameAdapter?.submitList(studentDataPagedList)
})
recyclerView.adapter = studentInfoNameAdapter
}
该Log
语句始终打印为零。我想显示一个TextView
if 列表为空,但列表始终返回大小为零。