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

删除数据时报索引越界 #277

Open
yebin254126 opened this issue Jul 28, 2021 · 6 comments
Open

删除数据时报索引越界 #277

yebin254126 opened this issue Jul 28, 2021 · 6 comments

Comments

@yebin254126
Copy link

添加删除列,点击该列时,如果是最后一行可以正常删除,如果不是最后一行,则数据删除后,没有更新colum的datas,然后遍历时引发索引越界 ,代码如下,尝试手动删除也不行。

            List<TurnIn> src = data_table.getTableData().getT();
            src.remove(position);
            data_table.getTableData().setT(src);
            table_columns.forEach(col -> {
                col.getDatas().remove(position);
            });
            data_table.notifyDataChanged();
@xinyangmaojian
Copy link

添加删除列,点击该列时,如果是最后一行可以正常删除,如果不是最后一行,则数据删除后,没有更新colum的datas,然后遍历时引发索引越界 ,代码如下,尝试手动删除也不行。

            List<TurnIn> src = data_table.getTableData().getT();
            src.remove(position);
            data_table.getTableData().setT(src);
            table_columns.forEach(col -> {
                col.getDatas().remove(position);
            });
            data_table.notifyDataChanged();

我试了 你的这个问题用data_table.invalidate()就能解决了
而我的问题是不remove,只修改其中一个类的属性,这个方法无效,不知道什么原因,郁闷。

@xinyangmaojian
Copy link

不要用notifyDataChanged()

@lozn00
Copy link

lozn00 commented Nov 18, 2021

。。神奇。 这方法不就是用来更新的吗

@lozn00
Copy link

lozn00 commented Nov 18, 2021

不要用notifyDataChanged()

一样的崩溃

@lozn00
Copy link

lozn00 commented Nov 18, 2021

      getBinding().tableview.notifyDataChanged();
            getBinding().tableview.invalidate();

这样虽然可以,但是高度问题。。

@JackyBower
Copy link

用这个SmartTable.getTableData().getT().remove 动态删除某一行数据,表格没变化,删除最后一行直接报 :
java.lang.IndexOutOfBoundsException: Index: 4, Size: 0

mSmartTable.notifyDataChanged();
mSmartTable.invalidate();

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

4 participants