0
Speak for yourself Blz? I’m a beginner in Kotlin and Firebase!
I’m trying to do a search on firebase in a collection that has user task data, I wanted to filter by ID, follow example:
My search at the moment is like this:
mDatabase.child("TAREFAS_USUARIOS").child(userid)
but that way it won’t and I can’t find another way on the net
Code:
class FrontPage: AppCompatActivity() {
lateinit var mRecyclerView : RecyclerView
lateinit var mDatabase : DatabaseReference
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_front_page)
mRecyclerView = findViewById(R.id.recycler_view)
mRecyclerView.setHasFixedSize(true)
mRecyclerView.layoutManager = LinearLayoutManager(this)
var uid: FirebaseAuth = FirebaseAuth.getInstance()
mDatabase = FirebaseDatabase.getInstance().reference
criarNovaTarefa.setOnClickListener {
startActivity(Intent(this, criar_tarefas::class.java))
finish()
}
logRecyclerView()
}
private fun logRecyclerView() {
var uid: FirebaseAuth = FirebaseAuth.getInstance()
var userid: String
userid = uid.uid.toString().trim()
var FirebaseRecyclerAdapter = object : FirebaseRecyclerAdapter<tasks_base,userViewHolder>(
tasks_base::class.java,
R.layout.list_view_task,
userViewHolder::class.java,
mDatabase.child("TAREFAS_USUARIOS").child(userid)
){
override fun populateViewHolder(viewHolder: userViewHolder, model: tasks_base, position: Int) {
viewHolder.itemView.task_title_view.text = model.task_name
viewHolder.itemView.task_description_view.text = model.task_description
viewHolder.itemView.task_type_view.text = model.task_type
viewHolder.itemView.view_task_fim.text = model.finish
viewHolder.itemView.view_task_inicio.text = model.init
}
}
mRecyclerView.adapter = FirebaseRecyclerAdapter
}
}
Share the part of the code where you receive the object and try to access it, and explain better what the problem is. It’s hard to help with such a general question
– Rafael Tavares
Hi Rafael! Follow the code
– Guilherme De Oliveira
Please, edit your question and put the code there :)
– Rafael Tavares
Thanks Rafael, I’m new here tb kkkk was bad
– Guilherme De Oliveira