1

When you are working with a long, big list, certainly one should use ListView because it handles cell recycling.

Notice here, for example Can i use nested linearlayouts instead of list view, for a big list? the OP is asking about ListView verses a dynamic LinearList -- the answer is "have to use a ListView, because of recycling"

Now, say you are making a short list -- imagine say a popup with only 10 or 20 items. It may even fit all on the one screen, so there's no recycling.

In fact, is there any difference between using a ListView and just using a LinearLayout, and dynamically populating the little views inside it?

It seems to me that the latter is in many cases much simpler, more elegant, and easier to work with. But I could well be missing something that seasoned Android engineers know about.

Should I just use an ordinary LinearList (populate it dynamically) for lists where recycling is not relevant? What's the usual, and why? Cheers!

{Incidentally, for popup cases, is there some better, lightweight method for "choose one from a popup-list" that I'm too silly to know about?! :) )

Community
  • 1
  • 1
Fattie
  • 27,874
  • 70
  • 431
  • 719

2 Answers2

1

ListView(and other lists) supports very useful idea: splitting data and view. These parts could be changed at any time so it's important to support flexibility. And it could be solved by special mediator object: Adapter. Adapter roughly speaking says how to fill your view with particular data item.

So I'm sure that if you decide to use LinearLayout sooner or later you will implement you own Adapter.

eleven
  • 6,779
  • 2
  • 32
  • 52
1

If you used dynamic linear view then rendering the view will take more time as compare to listview. In listview we are rendering views which are visible only but if you used dynamic linear view then its problem.

Peter DeWeese
  • 18,141
  • 8
  • 79
  • 101
Shrikant Salunkhe
  • 329
  • 1
  • 4
  • 14