0

i have this layout

I need to create new CheckBox when i press the button. CheckBox should be the same like the previous ones. This is my CheckBox code:

        <CheckBox
            android:id="@+id/"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="" />

1 Answers1

0

You should set onClick to this button:

  <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:onClick="ALO" />

.

public void ALO(View view) {

        LinearLayout ll = new LinearLayout(this);
        ll = (LinearLayout) findViewById(R.id.youridoflayout);
        CheckBox cb = new CheckBox(getApplicationContext());
        cb.setText("Hi there");
        ll.addView(cb);


    }