Skip to content Skip to sidebar Skip to footer

Check Box Checked Automatically In Listview When Scrolling The List.

I have one problem, i have customize listview with checkbox. When i scroll the items the some checkbox is automatically checked without clicking on checkbox. Can any one help me?

Solution 1:

works fine for me

public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {

        final ViewHolder holder;
        finalSeasonseason= (Season) getGroup(groupPosition);
        if (convertView == null) {
            LayoutInflatervi= (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = vi.inflate(R.layout.season, parent, false);
            holder = newViewHolder();
            holder.title = (TextView) convertView.findViewById(R.id.season_title);
            holder.checkBox = (CheckBox) convertView.findViewById(R.id.season_check_box);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.title.setText(season.getTitle());
        holder.checkBox.setOnCheckedChangeListener(newCompoundButton.OnCheckedChangeListener() {
            @OverridepublicvoidonCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                season.setChecked(isChecked);
                adapter.notifyDataSetChanged();
            }
        });

        holder.checkBox.setChecked(season.isChecked()); // position is important! Must be before return statement!return convertView;
    }

    protectedclassViewHolder {
        protected TextView title;
        protected CheckBox checkBox;
    }

Solution 2:

It means that ou select one checkbox and android will select randomly for that you should use...

if(tempVector.get(position)){
            holder.box.setChecked(true);
        }
        else{
            holder.box.setChecked(false);
        }

Try this, it works for me.

Post a Comment for "Check Box Checked Automatically In Listview When Scrolling The List."