Contents

Android Developer Reference

This is the official Google Android site for developers. Here you will find all the documentation you need to develop rich android applications.

You will most likely visit this site often.

All tutorials and sample code are credited to their respected owners.

Portions of this page are reproduced from work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Widgets

This topic covers the android widgets like TextView, EditText, ListViews, etc...

Before we delve into some of the widgets, we must first familiarize ourselves with the Adapter. The adapter is used to interface with the underlying data of certain list based widgets.

An Adapter object acts as a bridge between an AdapterView and the underlying data for that view. The Adapter provides access to the data items. The Adapter is also responsible for making a View for each item in the data set.

ArrayAdapter

Using an ArrayAdapter

Is this section we will learn about one of the easier Adapters to implement, the ArrayAdapter. all you need to do is wrap one of these around a Java array or java.util.List instance, and you have a fully-functioning Adapter.

One flavor of the ArrayAdapter constructor takes three parameters.

  1. The Context to use (typically this will be your activity instance).
  2. The resource ID of a view to use (such as a built-in system resource ID, as shown above.
  3. The actual array or list of items to show.

By default, the ArrayAdapter will invoke the toString() method on the objects in the list and wrap each of those strings in the view designated by the supplied resource. android.R.layout.simple_list_item_1 simply turns those strings into TextView objects. Those TextView widgets, in turn, will be shown in the list or spinner or whatever widget uses this ArrayAdapter. If you want to see what android.R.layout.simple_list_item_1 looks like, you can find a copy of it in your SDK installation - just search for "simple_list_item_1.xml".

Adapters will hopefully become more clear as you go through the topics on Widgets next.

Listed below are some of the widgets currently available here.

EditText
ListView
Spinner
TextView