我有问题。我正在用 Java / Android 编写 List Adapter。我覆盖了返回 View 的方法(它是 Clicked 项目的可消耗列表视图)。问题是:
Log.i 向我展示:
- 05-17 14:04:50.494: I/createTextView(21790): 0 06 Salame
- 05-17 14:04:50.504: I/createTextView(21790): 1 11 Pancetta
但是 TextViews 看起来两者兼而有之:
- 1 11 薄饼
- 1 11 薄饼
看起来 TextView 是指最后一个 TextView。如何解决?
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
Log.e("SecondLevelAdapter", "getGroupView");
TextView tv = new TextView(OrderFirstGridPage.this);
if((myArrayProductList.get(groupPosition).get(0).getFlgZlozony() == 1)) {
Log.i("createTextView", String.valueOf(counterProductName)+" "+myArrayProductList.get(groupPosition).get(counterProductName).toString());
tv.setText(myArrayProductList.get(groupPosition).get(counterProductName).toString());
counterProductName++;
}
tv.setPadding(22, 7, 7, 7);
tv.setGravity(Gravity.LEFT);
tv.setTextAppearance(OrderFirstGridPage.this, R.style.TextLarge);
tv.setTextSize(25);
return tv;
}