且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Checkedtextview 在滚动 Listview 后选中/取消选中

更新时间:2022-05-11 03:07:24

那是因为您传递的列表(项目)具有旧值.当您更改检查状态时,将其更新为填充的列表(项目)到列表视图.滚动列表视图将再次加载它们的项目,在那里它获取旧值.

Thats because your list(items) which you passed has the old value.When you change the check status,update it to the list(items) which is populated to the listview.On Scroll the list view will load them items again, where it is getting the old value.

vh.textView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        autoid = item.getAutoid();

        if (! finalVh.textView.isChecked()) {
            finalVh.textView.setChecked(true);
            item.setStatus("true")
        } else {
            finalVh.textView.setChecked(false);
            item.setStatus("false");
        }
        items.set(position, item);
    }
});