Search code examples
androiddynamiclayoutbuttonclickable

How to make a dynamic layout with clickable text, checkboxes and buttons?


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


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.