Git Product home page Git Product logo

点击事件回调方法onHeaderClick(View view, int id, int position)中,第一个参数(被点击的View)可能并不是真实标签中的view, 点击事件中刷新标签UI可能不生效 about pinnedsectionitemdecoration HOT 1 OPEN

liuyuttkx avatar liuyuttkx commented on September 27, 2024
点击事件回调方法onHeaderClick(View view, int id, int position)中,第一个参数(被点击的View)可能并不是真实标签中的view, 点击事件中刷新标签UI可能不生效

from pinnedsectionitemdecoration.

Comments (1)

liuyuttkx avatar liuyuttkx commented on September 27, 2024

需求:在点击粘性标签后,刷新对应标签的UI。
异常现象:当列表中的粘性标签只有一个时,可以刷新标签UI,如果有多个粘性标签时,就不能正常刷新UI。
原因: 粘性标签显示时,需要通过adapter创建或复用一个粘性标签,此时通过position可以获取对应的holder,而在源码中ClickBounds类设置view的时候,同一个View id(除了holder.itemView) 只会设置一次。所以,在标签更新后,view没有重新设置。而点击事件是根据view所在区域进行判断和回调的,并不是对应的View真正的点击事件。
源码如下:
public void setClickBounds(int id, View view) { ClickBounds bounds; if (mBoundsArray.get(id) == null) { bounds = new ClickBounds(view, view.getLeft(), view.getTop(), view.getLeft() + view.getMeasuredWidth(), view.getTop() + view.getMeasuredHeight()); mBoundsArray.put(id, bounds); } else { bounds = mBoundsArray.get(id); bounds.setBounds( view.getLeft(), view.getTop(), view.getLeft() + view.getMeasuredWidth(), view.getTop() + view.getMeasuredHeight()); } }

解决: 在如上代码中,应该在mBoundsArray.get(id) != null的情况下也将view设置到bounds对象中,这样就可以了。
感谢楼主写的标签库,功能很好,简单易用。

from pinnedsectionitemdecoration.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.