[英]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: 一些项目视图包含:
As this is dynamically generated depends on data, I am facing following issues : 由于这是根据数据动态生成的,因此我面临以下问题:
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 问题
If your ViewPager
is using a FragmentPagerAdapter
...then that will definitely be causing a lot of overhead and performance drag. 如果您的ViewPager
使用FragmentPagerAdapter
...,那肯定会导致很多开销和性能拖累。
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. 即使这样做有效,也会引起一些主要的性能问题。
GridView
: Same goes with the GridView
. GridView
: GridView
。 You should never ever place a GridView
within another ListView
. 永远不要将GridView
放在另一个ListView
。 Even if this worked, it'll cause some major performance problems. 即使这样做有效,也会引起一些主要的性能问题。
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 否则你会得到一些慢的表现
Carousel - I have no idea what API this is but if it scrolls vertically, then it's a no go. Carousel-我不知道这是什么API,但是如果它垂直滚动,那就不行了。
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
. 例如,尝试使用TableLayout
或GridLayout
而不是GridView
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.