Spinners are what Android calls their widget that displays drop-down lists . Why "spinner"? I have no idea...you'll have to ask Google. You can think of a Spinner as a close relative to a ListView; in fact, they are both sub-classed from the AdapterView class and function in very similar ways. Fortunately for you, since you already know how to work with ListViews, Spinners should be a breeze!
In order to introduce you to Spinners, we'll take what you've already done with ListViews in the Presidents List app and modify our code to use a drop-down list. Here are the steps:
<Spinner
android:id="@+id/president_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"/>
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
// Show the Up button in the action bar.
setupActionBar();
String fullURL = baseURL + "List_of_Presidents_of_the_United_States";
Spinner spinner = (Spinner) findViewById(R.id.president_spinner);
List presidentsList =
Arrays.asList(getResources().getStringArray(R.array.presidents));
spinner.setAdapter(
new ArrayAdapter(this,
android.R.layout.simple_list_item_1, presidentsList));
spinner.setOnItemSelectedListener(this);
webView = (WebView) findViewById(R.id.wiki_webview);
webView.getSettings().setJavaScriptEnabled(true);
progressBar = (ProgressBar) findViewById(R.id.progressbar);
initializeWebView();
webView.loadUrl(fullURL);
}
Sample Eclipse Project: Presidents Spinner