N
N
Neonoviiwolf2019-08-11 10:44:56
Android
Neonoviiwolf, 2019-08-11 10:44:56

How to save the id of a dynamically added View when flipping the device?

Kind
There is a fragment, it is dynamically filled View depending on the answer of a DB. I am assigning an ID to view.generateViewId(). I need these views to have the same ID after the rotation. How to do it without big crutches?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2019-08-11
@Neonoviiwolf

If there are a lot of views, then you need to think in the direction of reusing and refilling them (make a request to the database or cache in memory).
If not enough, then you can create static IDs in values/ids.xml

<item name="my_view_id" type="id">

...

R.id.my_view_id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question