简体   繁体   English

Recyclerview是否最适合不同的列表项视图

[英]Is Recyclerview is best for different List Item View

Currently, I am having a ListView with different list item view for each row (Most cases Different). 当前,我有一个ListView的每一行都有不同的列表项视图(大多数情况下是不同的)。 I am having 6 different item layout, I will add more in future, and I will have only like 5-15 list items, some time may be less and may be many in other cases. 我有6种不同的项目布局,以后会增加更多,而我只会有5至15个列表项,有时会更少,而在其他情况下可能会很多。

Some item views contains: 一些项目视图包含:

  • ViewPager ViewPager
  • ListViews 列表视图
  • ImageViews ImageViews
  • Texviews Texviews
  • Gridviews GridView的
  • CAROUSEL 旋转木马
  • Webviews 网页视图

As this is dynamically generated depends on data, I am facing following issues : 由于这是根据数据动态生成的,因此我面临以下问题:

  • Scrolling Slowly (Some Times) 缓慢滚动(有时)
  • List Item height 清单项目高度
  • Performance 性能

Is RecyclerView the best solution in this case? 在这种情况下, RecyclerView是最好的解决方案吗?

Without seeing your code to identify specific concerns, it's hard to address specific reasons why you are seeing such performance problems. 如果没有看到您的代码来识别特定的问题,就很难解决导致此类性能问题的特定原因。 Such as, are you properly using the ViewHolder paradigm? 例如,您是否正确使用ViewHolder范例? Or are you inappropriately loading stuff on the UI thread when it should be loaded on a background thread? 还是应该在后台线程上加载内容时不适当地在UI线程上加载内容? Android has a small section talking about scrolling smoothly with a ListView you should check out. Android有一小节讨论如何使用ListView 平滑滚动 ,您应该检查一下。 That aside,based on what you have mentioned so far...I think you major problem is design. 除此之外,根据您到目前为止提到的内容,我认为您的主要问题是设计。

Problems 问题

  1. If your ViewPager is using a FragmentPagerAdapter ...then that will definitely be causing a lot of overhead and performance drag. 如果您的ViewPager使用FragmentPagerAdapter ...,那肯定会导致很多开销和性能拖累。

  2. ListView : You should never ever place a ListView within another ListView . ListView :永远不要将ListView放在另一个ListView This will cause all sorts of problems. 这会引起各种各样的问题。 Android does not like embedding two scrollable widgets that scroll the same direction. Android不喜欢嵌入两个滚动相同方向的可滚动小部件 Even if this worked, it'll cause some major performance problems. 即使这样做有效,也会引起一些主要的性能问题。

  3. GridView : Same goes with the GridView . GridViewGridView You should never ever place a GridView within another ListView . 永远不要将GridView放在另一个ListView Even if this worked, it'll cause some major performance problems. 即使这样做有效,也会引起一些主要的性能问题。

  4. If you're ImageView is loading some large graphics, it should be on a background thread and not the UI thread. 如果您正在ImageView上加载一些大型图形,则它应该在后台线程上而不是UI线程上。 Else you'll get some slow performance 否则你会得到一些慢的表现

  5. Carousel - I have no idea what API this is but if it scrolls vertically, then it's a no go. Carousel-我不知道这是什么API,但是如果它垂直滚动,那就不行了。

  6. WebViews are a very heavy weight object. WebViews是一个非常重的对象。 I can definitely see this guy slowing things down, especially if it's loading a lot of content. 我绝对可以看到这家伙放慢了脚步,尤其是在加载很多内容的时候。

To build off what @Joffrey has said. 建立@Joffrey所说的话。 There are some major concerns in your choice of UI. 选择UI时,存在一些主要问题。 Based on what you are placing in this ListView tells me that you need to seriously rethink how to display your content to the user. 根据您在此ListView所放置的内容,可以告诉我,您需要认真考虑如何向用户显示内容。 Eg, try using a TableLayout or GridLayout instead of a GridView . 例如,尝试使用TableLayoutGridLayout而不是GridView

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

相关问题 RecyclerView 为列表中的每个项目使用不同的 ItemTouchHelper - RecyclerView with different ItemTouchHelper for each item on the list Android:将 OnClickListner 设置为 RecyclerView 中每个视图项的最佳方法 - Android: Best way to set OnClickListner to each view item in RecyclerView 如何在RecyclerView中使用StickHeader制作不同的视图项类型? - How to make different view item types with StickHeader in RecyclerView? 如何从 recyclerView 中的项目获取数据并在 editTexts 上的不同活动中查看它 - How to get data from an item in a recyclerView and view it in a different activity on editTexts 在RecyclerView中更新项目视图 - Update an item view in RecyclerView 具有不同高度的 RecyclerView 项目 - RecyclerView item with different height RecyclerView 列表项视图未更新(使用 DiffUtil.ItemCallback) - RecyclerView list item view not updating (using DiffUtil.ItemCallback) 如何将选定的recyclerview列表项更改为标记为其他颜色 - How to change selected recyclerview list item to be marked as a different color 如果我以不同的项目顺序提交相同的列表,则 ListAdapter 不会刷新 RecyclerView - ListAdapter not refreshing RecyclerView if I submit the same list with different item order 在recyclerview项目中列出 - List in recyclerview item
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM