Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Spinner and ListView?

Both have a data source (or adapter). It appeared to me that Spinner can be shown in drop-down form, while ListView can show all data on the view directly. The data for both are all from an ArrayList. They could be in String 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?

like image 380
learner1 Avatar asked Dec 22 '13 11:12

learner1


1 Answers

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.

like image 154
ilovepjs Avatar answered Sep 19 '22 20:09

ilovepjs