I am trying to create a function that store 3 editext values into an object when a button is pressed. These objects are stored into an mutablelist, which will be returned and displayed in a recycleview.
fun getWish(): MutableList<Wish>{
val wishes : MutableList<Wish> = ArrayList()
add_button.setOnClickListener {
val name= name_input.getText().toString()
val price= price_input.getText().toString()
val url= url_input.getText().toString()
val wishTemp = Wish(name, price, url)
wishes.add(wishTemp)
print(wishTemp)
print(wishes)
}
return wishes
}
The issue is the list is not displaying in the recycleview. The recycle view adapter is not the issue because it was tested with a test list. Is my implementation not working?
Print function shows reference values not the actual string. However, the 'wishes' list is added to everytime the button is pressed.