Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listview first item pre-checked issue #4

Open
insearching opened this issue Jan 7, 2016 · 1 comment
Open

Listview first item pre-checked issue #4

insearching opened this issue Jan 7, 2016 · 1 comment

Comments

@insearching
Copy link

I have a ListView with checkboxes which states I'm saving in ArrayList. After trying to recreate listview to edit this list, somehow first item get checked even if it wasn't checked. Data in list is correct, as I was checking it in all states, before and after editing. When I change your animate checkbox on default one everything work like a charm.

Below is the code snippet of my getView in BaseAdapter.

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final PersonItemsCount item = personItemsCheckedList.get(position);
        ViewHolder holder;
        View view = convertView;
        if (view == null) {
            view = inflater.inflate(R.layout.add_price_dialog_row, null);
            holder = new ViewHolder(view);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        holder.chb.setTag(item);
        holder.nameTv.setText(item.getPerson().getName());
        holder.chb.setChecked(item.isChecked());
        holder.chb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                PersonItemsCount clickedItem = (PersonItemsCount) v.getTag();
                boolean isChecked = !((AnimateCheckBox) v).isChecked();
                clickedItem.setChecked(isChecked);
                notifyDataSetChanged();
            }
        });

        holder.portionNp.setValue(item.getItemsCount());

        return view;
    }

Attaching sample of checkbox behavior.
1

Also attaching sample of listview with default checkboxes, just to make sure that program logic is correct.
2

@hanks-zyh
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants