简体   繁体   English

用于复合组件的Android View Holder

[英]Android View Holder for Compound Components

I have some compound components that are used as my ListView items. 我有一些复合组件用作我的ListView项目。 To increase the performance I use view holder to render my ListView item but as each one has a compound component inside, it is still slow and rendering each compound component requires inflating the component each time. 为了提高性能,我使用视图持有者来渲染我的ListView项,但由于每个项都有一个复合组件,因此它仍然很慢并且渲染每个复合组件需要每次都给组件充气。

Is there any way that I can use something like ViewHolder pattern for my compound component? 有什么办法可以为我的复合组件使用ViewHolder模式吗?

For ListView a good performance enhancement is using getTag() and setTag() methods to retain the views defined in a viewholder . 对于ListView ,良好的性能增强是使用getTag()setTag()方法来保留视图中定义的viewholder Then the views are not created again and reused in which you can just change content then. 然后,不会再次创建视图并重新使用,您可以在其中更改内容。

Besides this, RecyclerView is always a better choice. 除此之外, RecyclerView始终是更好的选择。

Ref :- 参考: -

  1. ( RecyclerView vs. ListView ) RecyclerView与ListView
  2. ( What is the working of setTag and getTag in ViewHolder pattern? ) ViewHolder模式中setTag和getTag的工作原理是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM