我有适配器。不幸的是,这个解决方案不好,因为列表是空的,可以滚动区域,如何防止呢?
此代码适配器:
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
ViewHolder viewHolder;
View rowView = convertView;
int NumberOfWords = GetNumberOfWords(position);
if(rowView == null)
{
rowView = inflater.inflate(R.layout.adapter_list, parent, false);
viewHolder = new ViewHolder();
viewHolder.MainText = (TextView)rowView.findViewById(R.id.MainText);
viewHolder.ItemText = (TextView)rowView.findViewById(R.id.ItemText);
viewHolder.Selection = (CheckedTextView)rowView.findViewById(R.id.DictionaryCheck);
rowView.setTag(viewHolder);
}
else
{
viewHolder = (ViewHolder) rowView.getTag();
}
if(NumberOfWords == 0)
{
rowView.setVisibility(View.GONE);
}
else
{
rowView.setVisibility(View.VISIBLE);
viewHolder.MainText.setText(values[position]);
viewHolder.ItemText.setText("Zawiera słów : " + NumberOfWords);
viewHolder.Selection.setVisibility(View.VISIBLE);
viewHolder.Selection.setChecked(IsInSelected(position));
}
return rowView;
}