jeudi 12 mai 2016

Generate ID android

I've created checkboxes programmatically, and i need to set layout_above for each of them( so they will be above each other) this code works in loop, so it will generate few checkboxes, but i need to set id. how should i properly generate it?

CheckBox checkBox = new CheckBox(getApplicationContext());
     RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams
        (RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.ABOVE, checkBox.getId());
        checkBox.setLayoutParams(layoutParams);
        checkBox.setWidth(getScreenWidth());
        checkBox.setText(questions.get(questionId).answers.get(index));
    ll.addView(checkBox);




Aucun commentaire:

Enregistrer un commentaire