What is the difference between Spinner and ListView?
From Spinner and List View docs:
Spinners provide a quick way to select one value from a set. In the default state, a spinner shows its currently selected value. Touching the spinner displays a dropdown menu with all other available values, from which the user can select a new one.
ListView is a view group that displays a list of scrollable items. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database query and converts each item result into a view that's placed into the list.
Even though they are implemented from the same underlying data type, what makes them difference is what you mentioned earlier - the way they look and portray the data. If you want in your application a way to only select one value from a set then use a spinner as that's what they are designed for. If you want to just display a list of data then use a list view. You would not use a spinner in this case as a spinner means you have to select one while actually you don't want to select anything.
Comments
-
learner1 almost 2 years
Both have a data source (or adapter). It appeared to me that
Spinner
can be shown in drop-down form, whileListView
can show all data on the view directly. The data for both are all from anArrayList
. They could be inString
type like this:<string-array name="Cities"> <item >Beijing</item> <item >Tokoy</item> <item >New York</item> <item >London</item> <item >Paris</item> <item >Berlin</item> <item >Moscow</item> <item >Hongkong</item> </string-array>
What are their differences?
-
learner1 over 10 yearsSo it is. thank you very much. scrollable items vs dropdown menu? they are seemingly no different. they share the same data type.
-
learner1 over 10 years@ilovepgs, Im waiting for the correct answer or virture answer. as soon as I think it will be an excellent answer, I will choose it as an accepted. However, I vote you one scrore.
-
learner1 over 10 years_ to only select one value from a set then use a spinner as thats what they are designed for. If you want to just display a list of data then use a listview. _ to be frank, listview can also do the trick. viseversa, now that you urgently wish to win accessable answer. I think I give it to yours. however I wish to get more answers for the question.
-
ilovepjs over 10 years@learner1 List views can do the trick but depending what you are designing you may not want to, the idea is to give you as the developer freedom in how you design your app. They're not exactly the same as spinners come with initialised values and do not support item click events.
-
learner1 over 10 yearsas if they do support clicking the event. happy new year.