I have a little problem I want show a menu in my action bar when own_product is true but when i change the value of my boolean the menu it still not visible, the boolean var change later.
private var own_product = false
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
println(own_product)
return if(own_product){
menuInflater.inflate(R.menu.product_details_menu,menu)
true
} else false
}
fun myfunction(){
productViewModel.getProductById(id).observe(this, Observer {
product = it
if(product.user_id == auth.currentUser!!.email){
own_product = true
}
println(own_product)
title.text = product.title
description.text = product.description
date.text = product.date.toString()
image.setImageBitmap(product.image)
price.text = product.price.toString() +"€"
}
How can I solve this problem?