Give me please an advise, I want to make a dynamic layout which contains mixed elements [text] [checkbox] [button] [text] [checkbox] [button] [text] [checkbox] [button] ......
Can you give me some sample code, please
Give me please an advise, I want to make a dynamic layout which contains mixed elements [text] [checkbox] [button] [text] [checkbox] [button] [text] [checkbox] [button] ......
Can you give me some sample code, please
The accepted answer to question 2216811 shows how to do this with LayoutInflater.
final TableLayout Tlayout = new TableLayout(getApplicationContext());
Trow = new TableRow(getApplicationContext());
checkBox = new CheckBox(getApplicationContext()); Trow.addView(checkBox);
button = new Button(getApplicationContext()); button.setText("Button"); Trow.addView(button);
textBox = new EditText(getApplicationContext()); textBox.setText("default_value"); Trow.addView(textBox);
This code may help you to create dynamic form elements
Hi,
i have the same problem, and tried your code. first of all, thx for helping us :) but
I actually don1t know, how it works. to see these components there should be an .xml file, which defines the layout of the application - but your code doesn't generate such a file, and I actually don't see anything on screen.
could you help me?
i'd like to make a shopping list program. the user can add items to list - the new item appears on screen with quantity, and there's a checkbox too (if the item is bought or not) but I don't know how many items will be there - and I wouldn't like to declare 3000 Layouts and TextViews and CheckBoxes in .xml, and of course, i won't write 3000 times, what happens, when I'm adding a new item - the difference will be only the layout-item, and I can't write a function, because of R.id."itemName" <-because it's not php :( :) do you have an idea, how to solve this problem?
once more thx for helping :) bye, Petra
p.s: sry for my english :P