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

notifyDataSetChanged 之后自动关闭的问题 #567

Open
qq870841070 opened this issue Aug 24, 2022 · 4 comments
Open

notifyDataSetChanged 之后自动关闭的问题 #567

qq870841070 opened this issue Aug 24, 2022 · 4 comments

Comments

@qq870841070
Copy link

调用 notifyDataSetChanged 布局会自动关闭,翻了好久没找到解决办法,后来我重写了OnLayout方法,临时解决一下
@OverRide
protected void onLayout(boolean changed, int l, int t, int r, int b) {
if (isDisableLayout){

        return;
    }
    super.onLayout(changed, l, t, r, b);
    LogUtils.debug("更新布局");
}


//使用notifyDataSetChanged 前,先禁用OnLayout事件
public void setDisableLayout(boolean _disable){
    this.isDisableLayout = _disable;
}

使用notifyDataSetChanged之后,在调用listView的layout方法,不知道为什么要加个随机数,否则两次调用layout参数都一致的话也不会更新
listView.layout(0,0,1000+ RandomUtils.getRandom(1,100),2000);

@Dieselkaka
Copy link

Dieselkaka commented Aug 24, 2022 via email

@HeroGentry
Copy link

HeroGentry commented Aug 24, 2022 via email

@uidq1290
Copy link

uidq1290 commented Aug 24, 2022 via email

@qq870841070
Copy link
Author

    int left = listView.getLeft();
    int right = listView.getRight();
    int top = listView.getTop();
    int bottom = listView.getBottom();
    Date dt = new Date();
    int sec = dt.getSeconds();
    listView.layout(0,0,right,bottom+sec);

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