我无法在 Fragment 的 RecyclerView 中适配 RecyclerView
I Can't adapt RecyclerView in RecyclerView at Fragment
使用科特林。
我想在parentRecyclerView中创建childRecyclerView。
也许我认为这个问题来自 recyclerView 适配器。
正在从 Firebase 获取数据。 (云 Firestore)
我完成了'parent RecyclerView'。
而且我还在parentRecyclerView的adapter上写了childRecyclerView的适配代码。
在 parentRecyclerView 中,我要求接收 childRecyclerView 的 Firebase 数据
我通过日志检查了这个数据是否被很好地接收了。
但是我的应用只显示 parentRecyclerView 的内容。
这段代码是在ParentRecyclerView的adapter中适配ChildRecyclerView的代码。
我在 ParentRecyclerView 的 bind() 函数中编写了这段代码。这个乐趣还包括显示 ParentRecyclerView 的内容(就像 Glide for parentRecyclerView 的 ImageView)。
val db = FirebaseFirestore.getInstance()
val queryText2: Query = db.collection("spiceTable")
var queryText3: Query
val storageRef2 = Firebase.storage.reference.child("scentnote/spiceimage")
var j: Int = 1
var detailSpiceList = mutableListOf<SpiceDetailValue>()
queryText2.get().addOnSuccessListener { documents ->
//Loop in parentRecyclerView's content
.addOnSuccessListener { documentx ->
//Getting ChildRecyclerView's content from Firebase
}.addOnCompleteListener {
nAdapter = context?.let { NoteSubRecyclerviewAdapter(it, detailSpiceList) }
fragment2NoteParentItemBinding?.fragment2NoteChildList?.adapter = nAdapter
val gridLayoutManager = GridLayoutManager(context, 4)
fragment2NoteParentItemBinding?.fragment2NoteChildList?.layoutManager = gridLayoutManager
}
detailSpiceList = mutableListOf<SpiceDetailValue>()
从“.addOnCompleteListener”到“~gridLayoutManager}”代码与在我的 Fragment 上适配 ParentRecyclerView 相同。 (在代码中,fragment2Note)
我尝试在 addOnSuccessListener 末尾和 addOnCompleteListener 开始时登录。
并且 addOnCompleteListener 的日志显示速度比 addOnSuccessListener 的日志快。
我不知道为什么这段代码会这样工作。
而且我也不知道为什么这个适配器不能工作。
在Logcat,
No adapter attached; skipping layout
这个日志显示了好几次,但我不知道他们的原因。
请帮忙...
对不起,因为我不擅长英语
请这样做
在第一阶段用空数据声明适配器。
val db = FirebaseFirestore.getInstance()
val queryText2: Query = db.collection("spiceTable")
var queryText3: Query
val storageRef2 = Firebase.storage.reference.child("scentnote/spiceimage")
var j: Int = 1
var detailSpiceList = mutableListOf<SpiceDetailValue>()
nAdapter = context?.let { NoteSubRecyclerviewAdapter(it, detailSpiceList) }
fragment2NoteParentItemBinding?.fragment2NoteChildList?.adapter = nAdapter
val gridLayoutManager = GridLayoutManager(context, 4)
fragment2NoteParentItemBinding?.fragment2NoteChildList?.layoutManager = gridLayoutManager
queryText2.get().addOnSuccessListener { documents ->
//Loop in parentRecyclerView's content
.addOnSuccessListener { documentx ->
//Getting ChildRecyclerView's content from Firebase
// After getting data, you asssign data to adapter
adapter.setItem(detailSpiceList); // You need to create function to attach data to adapter. (it is easy and common way)
}.addOnCompleteListener {
}
使用科特林。
我想在parentRecyclerView中创建childRecyclerView。 也许我认为这个问题来自 recyclerView 适配器。
正在从 Firebase 获取数据。 (云 Firestore)
我完成了'parent RecyclerView'。 而且我还在parentRecyclerView的adapter上写了childRecyclerView的适配代码。 在 parentRecyclerView 中,我要求接收 childRecyclerView 的 Firebase 数据 我通过日志检查了这个数据是否被很好地接收了。 但是我的应用只显示 parentRecyclerView 的内容。
这段代码是在ParentRecyclerView的adapter中适配ChildRecyclerView的代码。 我在 ParentRecyclerView 的 bind() 函数中编写了这段代码。这个乐趣还包括显示 ParentRecyclerView 的内容(就像 Glide for parentRecyclerView 的 ImageView)。
val db = FirebaseFirestore.getInstance()
val queryText2: Query = db.collection("spiceTable")
var queryText3: Query
val storageRef2 = Firebase.storage.reference.child("scentnote/spiceimage")
var j: Int = 1
var detailSpiceList = mutableListOf<SpiceDetailValue>()
queryText2.get().addOnSuccessListener { documents ->
//Loop in parentRecyclerView's content
.addOnSuccessListener { documentx ->
//Getting ChildRecyclerView's content from Firebase
}.addOnCompleteListener {
nAdapter = context?.let { NoteSubRecyclerviewAdapter(it, detailSpiceList) }
fragment2NoteParentItemBinding?.fragment2NoteChildList?.adapter = nAdapter
val gridLayoutManager = GridLayoutManager(context, 4)
fragment2NoteParentItemBinding?.fragment2NoteChildList?.layoutManager = gridLayoutManager
}
detailSpiceList = mutableListOf<SpiceDetailValue>()
从“.addOnCompleteListener”到“~gridLayoutManager}”代码与在我的 Fragment 上适配 ParentRecyclerView 相同。 (在代码中,fragment2Note) 我尝试在 addOnSuccessListener 末尾和 addOnCompleteListener 开始时登录。
并且 addOnCompleteListener 的日志显示速度比 addOnSuccessListener 的日志快。 我不知道为什么这段代码会这样工作。 而且我也不知道为什么这个适配器不能工作。
在Logcat,
No adapter attached; skipping layout
这个日志显示了好几次,但我不知道他们的原因。
请帮忙... 对不起,因为我不擅长英语
请这样做
在第一阶段用空数据声明适配器。
val db = FirebaseFirestore.getInstance()
val queryText2: Query = db.collection("spiceTable")
var queryText3: Query
val storageRef2 = Firebase.storage.reference.child("scentnote/spiceimage")
var j: Int = 1
var detailSpiceList = mutableListOf<SpiceDetailValue>()
nAdapter = context?.let { NoteSubRecyclerviewAdapter(it, detailSpiceList) }
fragment2NoteParentItemBinding?.fragment2NoteChildList?.adapter = nAdapter
val gridLayoutManager = GridLayoutManager(context, 4)
fragment2NoteParentItemBinding?.fragment2NoteChildList?.layoutManager = gridLayoutManager
queryText2.get().addOnSuccessListener { documents ->
//Loop in parentRecyclerView's content
.addOnSuccessListener { documentx ->
//Getting ChildRecyclerView's content from Firebase
// After getting data, you asssign data to adapter
adapter.setItem(detailSpiceList); // You need to create function to attach data to adapter. (it is easy and common way)
}.addOnCompleteListener {
}