The type of adapter you are using should depend on the type of data you are trying to present. Adapters ideally represent a very thin object that associates elements from your dataset with representations. The ArrayAdapter provides this for small, limited datasets; the CursorAdapter provides this for datasets resulting from an SQLite query.
Not all data sets will fit into the forms presented in adapter classes in the Android platform, but writing them is easy. Listing all positive integers is a good example, because it doesn't need to bind to the underlying data model at all. Although saving a sliding window to a large data set may be a useful approach for some data, it is not needed here.
Start with the BaseAdapter :
public class IntRangeAdapter extends BaseAdapter { private LayoutInflater mInflater; private int mItemResource; public IntRangeAdapter(Context context, int itemLayout) {
Using it from your published operation code will consist of modifying the setAdapter call and removing the loop to configure the data:
this.setListAdapter(new IntRangeAdapter(this, android.R.layout.simple_list_item_1));
If you need more information on using ListViews, this talk from Google I / O 2010 provides a decent introduction: http://www.youtube.com/watch?v=wDBM6wVEO70
source share