Android views as templates

I want to create an android layout from which I want to create multiple copies. I understand that declaring a layout in XML will create one instance. Is there a way to use the XML View declaration as a "definition" rather than a "declaration"? Or can I clone a show?

thank

+3
source share
4 answers

What do you mean by an instance of multiple instances? In the same activity? Or in different events?

You can inflate the layout using LayoutInflater . This will allow you to create multiple instances of the view in the same action.

, , ListView, .

+4

, xml, LayoutInflater, .

, .

0

, inflate (int resource, ViewGroup root) LayoutInflater. null .

However, you should keep in mind that LayoutInflator is quite expensive and should be used as little as possible.

0
source

Source: https://habr.com/ru/post/1763920/


All Articles