如何在Kotlin中将Groupie与Firestore一起使用

时间:2020-02-28 22:50:14

标签: kotlin google-cloud-firestore

请告诉我们如何使用groupie在应用程序本身中显示数据(我是从firestore中获取的)。这是我正在使用kotlin的代码,我想在我的应用程序中显示数据,这是我的学习阶段,我将感谢任何能帮助我的人

        val adapter = GroupAdapter<ViewHolder>()

        adapter.add(UserItem())
        recview.adapter = adapter
        fetchuser()


        adapter.setOnItemClickListener { item, view ->

            val intent = Intent (this, Chat::class.java)
            startActivity(intent)

        }    

    }

    val TAG = "My message"
    val db = FirebaseFirestore.getInstance()
    private fun fetchuser(){
        db.collection("doctors")
            .get()
            .addOnSuccessListener { result ->
                for (document in result) {
                    Log.d(TAG, "${document.id} => ${document.data}")

                }
            }
            .addOnFailureListener { exception ->
                Log.d(TAG, "Error getting documents: ", exception)
            }


    }

    override fun onSupportNavigateUp(): Boolean {
        onBackPressed()
        return true
    }
}

class UserItem: Item<ViewHolder>(){
    override fun bind(viewHolder: ViewHolder, position: Int) {

    }

    override fun getLayout(): Int {

        return R.layout.user_row

    }

}

0 个答案:

没有答案