P
P
PoisonousHeart2021-08-10 10:57:34
Android
PoisonousHeart, 2021-08-10 10:57:34

Why do the onRestoreInstanceState and onSaveInstanceState methods in the custom viewGroup work only if an id is added?

If there is another way to achieve them, how? Or how to create some kind of permanent id inside him?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2021-08-10
@PoisonousHeart

Because this ID is used to save to the bundle. Imagine a situation when you added two of your views to one layout, and they had a different state - how to save them in one bundle? This is where the ID will help. And if you make a "permanent ID", then, obviously, it will be the same for them, and in the situation described, everything will simply fall.
The answer is that it should be. The state of the view is saved only if it has an ID, this is normal and correct.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question