R
R
Romanchitoz2018-06-10 00:05:50
Java
Romanchitoz, 2018-06-10 00:05:50

How to change the other one when clicking on one element of the list?

There is a list , each element of the list has a button , which has two "text" states "Play" and "Stop". How can I make it so that if I clicked on the button of the first list item (on which Play changed to Stop), when I clicked on the button of another list item, the text of the button of the first one changed back to Play.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2018-06-10
@zagayevskiy

The list is represented by a model (an array or a list of objects mapped to the UI). The click event must reach the entity driving the logic (this is by no means a List/RecyclerView adapter). For example, this is a presenter. This entity should change the model (list of objects) and cause UI changes. The UI layer must notify the adapter about the change and then the UI will be redrawn.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question