mercredi 11 mars 2020

Add checkbox dynamically for 2 in column

Need to show 2 checkboxes in a row. Below is my response data

response = "{\"target_marget\":[{\"name\":\"Bank\",\"id\":1},{\"name\":\"Insurance\",\"id\":2},{\"name\":\"Car Dealers\",\"id\":3},{\"name\":\"Dentists\",\"id\":4},{\"name\":\"Doctors\",\"id\":5},{\"name\":\"Bank\",\"id\":6},{\"name\":\"Insurance\",\"id\":7},{\"name\":\"Car Dealers\",\"id\":8},{\"name\":\"Dentists\",\"id\":9},{\"name\":\"Doctors\",\"id\":10}]}";

For that, I have dynamically added checkbox but it gives the result as one column of the checkbox

 for (int i = 0; i < targetMarketArrayList.size(); i++) {
        CheckBox checkBox = new CheckBox(this);
        checkBox.setText(targetMarketArrayList.get(i).getName());
        parentLayout.addView(checkBox);
    }

In Simple,

What it Does Now:

item1

item2

item3

item4

item5

What I Want:

item1 item2

item3 item4

item5




Aucun commentaire:

Enregistrer un commentaire