我正在使用自定义适配器,每行都有使用创建的按钮数量,
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowview = (HorizontalScrollView) inflater.inflate(
R.layout.hrowlayout, parent, false);
LinearLayout ll1 = (LinearLayout) rowview.findViewById(R.id.ll);
Button[] b = new Button[M];
for (int i = 0; i < M; i++) {
b[i] = new Button(ll1.getContext());
b[i].setText(....);
LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams( x, 90);
b[i].setLayoutParams(param2);
ll1.addView(b[i],params2);
}
return rowview;
}
我的问题是如何在此适配器上使用 ViewHolder 以及如何标记不在 XML 文件中的按钮 .. 即在
b[i] = new Button[M];