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

onCreateViewHolder #30

Open
Alex-Cin opened this issue Nov 16, 2018 · 2 comments
Open

onCreateViewHolder #30

Alex-Cin opened this issue Nov 16, 2018 · 2 comments

Comments

@Alex-Cin
Copy link

Alex-Cin commented Nov 16, 2018

HI,你好啊。 我这边的日志发现,onCreateViewHolder执行了 好多次 ;
我记得,adapter 的oncreate方法,不应该执行这么多次的,有时间的话,你可以看一下啦;
比如我的 adapter.list 有120个,这么多;

    @Override
    public WebBannerAdapter.MzViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        LogTrack.i("create  "+(createCount++));
        return new MzViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_image, parent, false));
    }

执行了 好多次

2018-11-16 14:25:29.784 26475-26475/com.renny.recyclerbanner I/LogTrack: [ (WebBannerAdapter.java:43) #onCreateViewHolder] create  0
2018-11-16 14:25:29.792 26475-26475/com.renny.recyclerbanner I/LogTrack: [ (WebBannerAdapter.java:49) #onBindViewHolder] bind 0
2018-11-16 14:25:29.816 26475-26475/com.renny.recyclerbanner I/LogTrack: [ (WebBannerAdapter.java:43) #onCreateViewHolder] create  1

...
2018-11-16 14:25:55.410 26475-26475/com.renny.recyclerbanner I/LogTrack: [ (WebBannerAdapter.java:49) #onBindViewHolder] bind 118
2018-11-16 14:25:55.709 26475-26475/com.renny.recyclerbanner I/LogTrack: [ (WebBannerAdapter.java:43) #onCreateViewHolder] create  121
2018-11-16 14:25:55.711 26475-26475/com.renny.recyclerbanner I/LogTrack: [ (WebBannerAdapter.java:49) #onBindViewHolder] bind 119

@haoyuegongzi
Copy link

haoyuegongzi commented Nov 27, 2018 via email

@Alex-Cin
Copy link
Author

Alex-Cin commented Dec 1, 2018

@haoyuegongzi
onCreateViewHolder 这个方法,不会被执行好多次的,相反onBindViewHolder才是被执行好多次的。就是 视图不会被反复创建, 但是会被反复绑定的。 是这样子的吧

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

2 participants