A
A
andre_macareno2014-07-18 21:12:12
Android
andre_macareno, 2014-07-18 21:12:12

Android: Is it possible to cache the contents of Layouts?

Good day.
There is a ListView, and inside it a couple more LinearLayouts are dynamically inflated.
I noticed that in some cases it takes too long to create them, and I thought about caching the content.
Actually, the question is: is it possible to start, for example, LruCache, which would store objects of the LinearLayout class, and somehow reuse them?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
andre_macareno, 2014-07-19
@andre_macareno

Well, I'll answer my own question.
If you have some kind of list, in the elements of which more layouts are dynamically inserted, the best option would be to create an LruCache that will store these layouts.
And then they are simply deleted in getView() and re-inserted from LruCache (deletion is required so that the program does not crash with "The specified child already has a parent").

M
Marat S, 2014-07-19
@aratj

1. get rid of unnecessary nesting
2. use holders, at least the first level will not be created.
3. And what is meant by content, only layouts?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question