我在每行中都有列表项,如:
item1 item2 item3 item4 item5 item6
我需要
第1项第2项第3项
第4项第5项第6项 ...
我不需要使用GridView。我的getView():
LinearLayout dynamicallyLayout = null;
boolean needCreated = true;
if (json.length() > 1) {
for (int j = 0; j < json.length(); j++) {
JSONObject classesJson = json.getJSONObject(j);
String name = classesJson.getString("name");
classChbx = new CheckBox(ctx);
classChbx.setText(name);
if (value == 1) classChbx.setChecked(true);
if (needCreated) {
dynamicallyLayout = new LinearLayout(ctx);
dynamicallyLayout.setOrientation(LinearLayout.HORIZONTAL);
holder.llChbTypes.addView(dynamicallyLayout);
needCreated = false;
}else {
if (j % 3 == 0) {
needCreated = true;
dynamicallyLayout.addView(classChbx);
dynamicallyLayout = null;
break;
}
}
if (dynamicallyLayout != null)
dynamicallyLayout.addView(classChbx);
}
}else {
classChbx = new CheckBox(ctx);
classChbx.setText(json.getJSONObject(0).getString("name"));
holder.llChbTypes.addView(classChbx);
}
但它寻找低分辨率,如:item1,item2,item3 ..这就是全部!
答案 0 :(得分:0)
我在我的代码中使用了这种方法。
for ( int i = 0 ; i < 4 ; i ++ )
{
LinearLayout layoutInWhichToAdd= (LinearLayout) rootView
.findViewById(R.id.layoutInWhichToAdd);
View toadd= orderDetails.getLayoutInflater().inflate(
R.layout.include_items_invieworder, layoutInWhichToAdd,
false);
layoutInWhichToAdd.addView(toadd);
}