android:orientation="vertical",为竖向的,默认。
android:orientation="horizontal",才为横向的
你需在Layout的xml配置上加上这句//
final CheckBox checkBox=new CheckBox(context);
//可以用findViewById()方法从xml找
checkBoxsetOnCheckedChangeListener(new CompoundButtonOnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
//选中的CheckBox 的内容
String text= checkBoxgetText()toString();
}
}
});用findviewbyid找到实例,定义一个实例名称去存储。然后比如你的checkbox的id是mycheckbox然后就是mycheckboxsetchecked();这样就是在选中状态了。
希望对你有帮助。5个 LinearLayout 的id放到一个int数组里 5个checkbox的id也放到一个int数组里
点击到那个索引的checkbox就去get LinearLayout的数组
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)