androidandroid-listviewandroid-linearlayoutandroid-scrollview

What is better, listview or a linearlayout in scrollview when items are very limited?


I will have a screen in which there will be 11 images one below the other, so thus the list will only have one image per row. Now, I was confused in using a listview with custom adapter or a linearlayout contained by scrollview? What would be better?


Solution

  • The benefit of a listview is that all the items are not all created in the memory. So what happens is that if the number of visible items in your list are 10, then there will be 11 items created and as you scroll the ones which go out of view are deleted and the ones that come in view are created. This is handled by the listview.

    In your case, this will not happen. All 11 items will be in the memory. No matter whether they are in view or not. So I guess it depends upon ure memory handling. Other than u shouldnt have any issues as they are static. OnClick() can be done in the imageview itself. So u r good to go :)