简体   繁体   中英

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). 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.

Some item views contains:

  • ViewPager
  • ListViews
  • ImageViews
  • Texviews
  • Gridviews
  • 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?

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? Or are you inappropriately loading stuff on the UI thread when it should be loaded on a background thread? Android has a small section talking about scrolling smoothly with a ListView you should check out. 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.

  2. ListView : You should never ever place a ListView within another ListView . This will cause all sorts of problems. Android does not like embedding two scrollable widgets that scroll the same direction. Even if this worked, it'll cause some major performance problems.

  3. GridView : Same goes with the GridView . You should never ever place a GridView within another 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. 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.

  6. WebViews are a very heavy weight object. 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. There are some major concerns in your choice of 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. Eg, try using a TableLayout or GridLayout instead of a GridView .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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