我正在实现一个自定义列表视图适配器,以使用复选框创建多选列表视图。
问题是在适配器中的getView()方法上添加复选框时,该行会使高度变小。
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Context context = getContext();
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(mCellResourceId, parent, false);
T element = getItem(position);
if (mEditMode) {
LinearLayout linearLay = (LinearLayout) rowView.findViewById(android.R.id.widget_frame);
CheckBox check = new CheckBox(mContext);
check.setOnCheckedChangeListener(this);
linearLay.addView(check, 0);
}
setDataToRow(element, rowView);
return rowView;
}