我正在创建复选框列表,数据来自数据库。复选框是动态呈现的。但是问题是,列表要么是水平方向出现的,要么是垂直方向出现的。我想以表格形式列出列表。
stateManager.Instance.getDefectListFromServer(new ICallback() {
@Override
public void run() {
defectArrayList = stateManager.Instance.defectList;
for (Defect defect:defectArrayList) {
final CheckBox frontButton = new CheckBox(instance);
frontButton.setText(defect.name);
frontButton.setTag(defect);
frontButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
instance.onCheckboxClicked(v);
}
});
switch (defect.type)
{
case Front:
frontList.addView(frontButton);
break;
case Lining:
liningList.addView(frontButton);
break;
case Sleeve:
sleeveList.addView(frontButton);
break;
case Assembly:
assemblyList.addView(frontButton);
break;
}
}