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?
They're completely different. A ScrollView is simple a scrolling container you can use to scroll whatever you put inside it, which might be a list of items, or it might not. A ListView is very specifically designed to hold lists, where items typically look the same (or at least follow a pattern, e.g. section headings).
ScrollView is a subclass of FrameLayout , which means that you can place only one View as a child within it; that child contains the entire contents to scroll.
Android ListView is a ViewGroup that is used to display the list of items in multiple rows and contains an adapter that automatically inserts the items into the list. The main purpose of the adapter is to fetch data from an array or database and insert each item that placed into the list for the desired result.
Is ListView scrollable by default? scrollable Boolean|String (default: false) If set to true the listview will display a scrollbar when the content exceeds the listview height value. By default scrolling is disabled. It could be also set to endless in order to enable the endless scrolling functionality.
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 :)
Base on your requirement, a scrollview would be enough.
Unless:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With