在listview中隐藏行

时间:2013-04-14 12:52:53

标签: android listview hide element

我有适配器。不幸的是,这个解决方案并不好,因为列表是空的,你可以在该区域滚动,如何防止呢?

此代码适配器:

@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;
        }

0 个答案:

没有答案