1

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?

Joffrey
  • 32,348
  • 6
  • 68
  • 100
Saleeh
  • 392
  • 4
  • 15
  • 1
    Wow, are you putting all that stuff in items of a list? – Joffrey Oct 06 '14 at 11:58
  • @Joffrey Yea, I can't make and xml for that (Because it dynamically loaded from web service) For that i need an adapter,First i tried https://github.com/frankiesardo/LinearListView It sucks in many places so i done with Listview ,but now i have performance issues, Can you tell me best way to do it Thanks – Saleeh Oct 06 '14 at 12:03
  • I was more commenting on the kind of UI that would produce, rather than the performance aspect. Doesn't it look weird? Do you have a screenshot (out of curiosity)? If you want a scrollable list of items, then IMO the `ListView` is the way to go, with a well designed adapter using multiple view types. If this causes performance issues then maybe the recycling is not managed properly. – Joffrey Oct 06 '14 at 12:06
  • Your other option would be to dynamically add elements to a `LinearLayout`, but if you have 15 items, it might be worse in terms of performance. – Joffrey Oct 06 '14 at 12:14
  • How can you have a `ListView` within an item of a `ListView`? How is the user supposed to interact with that? – Joffrey Oct 06 '14 at 12:16
  • @Joffrey Listview inside Listview i will set height of inner listview to max so Scroll is not any issue any more, – Saleeh Oct 06 '14 at 12:24
  • Mmmh ok, but it sounds really weird to me. Since there will be no scroll on the inner `ListView`, is it really appropriate in the firts place? Also, your layout seems very complicated, I'm just wondering how users would deal with it. – Joffrey Oct 06 '14 at 12:35

1 Answers1

2

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.

Community
  • 1
  • 1
Ifrit
  • 6,791
  • 8
  • 50
  • 79