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

添加二级菜单的指定位置addSubItem(position, subItem); #2583

Closed
easyandroid opened this issue Dec 23, 2018 · 2 comments
Closed

添加二级菜单的指定位置addSubItem(position, subItem); #2583

easyandroid opened this issue Dec 23, 2018 · 2 comments

Comments

@easyandroid
Copy link

easyandroid commented Dec 23, 2018

分组拖动,移除后添加
int position = holder.getAdapterPosition();
int parentPosition = getParentPosition(getItem(position));
Level1Item subItem = new Level1Item("新添加" + position, "");
((Level0Item) getData().get(parentPosition)).addSubItem(position, subItem);
((Level0Item) getData().get(parentPosition)).getSubItems();
addData(position + 1, subItem);
position 应该怎么算插入的位置。
在AbstractExpandableItem 里面
public void addSubItem(int position, T subItem) {
if (mSubItems != null && position >= 0 && position < mSubItems.size()) {
mSubItems.add(position, subItem);
} else {
addSubItem(subItem);
}
}

@easyandroid easyandroid changed the title 添加二级菜单的指定位置 添加二级菜单的指定位置addSubItem(position, subItem); Dec 23, 2018
@CymChad
Copy link
Owner

CymChad commented Jul 13, 2019

收到

@shichaohui
Copy link
Collaborator

由于这个问题提出的比较久了,而且描述的不是很清楚,因此先行关闭。
如果您已经解决该问题,可以在下方回复解决方案。
如果您还有遇到此问题,请参考 #2807 重新提交 Issue 。

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

3 participants