In general, you need to dynamically display items for input on the screen. Suppose there is a file (well, whatever), in which it is written that we should have 2 input fields, 3 box sheets, and 2 labels. Here's how to add them to the screen dynamically? In the future, you need the ability to receive data from files and send them. The number of elements is not limited, it all depends on the source data obtained to create them.
1 answer
for(int i = 0; i< text.lines; i++) { if(line[i].Contains("Button") { Button b = new Button(getApplicationContext()); b.... // Назначаем параметры ... _linearLayout.Children.Add(b); } else if(line[i].Contains("Gallery"){ ... _linearLayout.Children.Add(...); } }
What is difficult?
- Well, the data from them is how to receive?) The battons can be 10, let's say everyone will have the name b? - AndroidDev
- At the activation level, make an array (or other structure), and push another b into it. Learn Java and Androdovsky java.util - Anton Osenenko
|