How To Make A New Checkbox Appear On Clicking Button In Android
How can I create a new checkbox every time I click a button and how do I hide a check box? Also, why doesn't checkbox.setVisibility(View.Gone); work the same way textview.setVisibi
Solution 1:
LinearLayout my_layout = (LinearLayout)findViewById(R.id.my_layout);
button.setOnClickListener(newonClickListener(){
voidonClick(){
CheckBox checkBox = newCheckBox(this);
checkBox.setText(Str_Array[i]);
my_layout.addView(checkBox);
}
});
Solution 2:
Create the checkbox in the layout and set visibility to View.GONE
, and when you need set visibility to View.VISIBLE
to show the checkbox
More info here
Post a Comment for "How To Make A New Checkbox Appear On Clicking Button In Android"