Question

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

Was it helpful?

Solution

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);

Tlayout.addView(Trow);

This code may help you to create dynamic form elements.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top