完整内容,请查看:http://www.zhdoc.net/android/reference/android/widget/SimpleAdapter.html
SimpleAdapter
public class SimpleAdapter
extends BaseAdapter
implements Filterable, ThemedSpinnerAdapter
java.lang.Object | ||
↳ | android.widget.BaseAdapter | |
↳ | android.widget.SimpleAdapter |
An easy adapter to map static data to views defined in an XML file. You can specify the data backing the list as an ArrayList of Maps. Each entry in the ArrayList corresponds to one row in the list. The Maps contain the data for each row. You also specify an XML file that defines the views used to display the row, and a mapping from keys in the Map to specific views. Binding data to views occurs in two phases. First, if a SimpleAdapter.ViewBinder
is available, setViewValue(android.view.View, Object, String)
is invoked. If the returned value is true, binding has occurred. If the returned value is false, the following views are then tried in order:
- A view that implements Checkable (e.g. CheckBox). The expected bind value is a boolean.
- TextView. The expected bind value is a string and
setViewText(TextView, String)
is invoked. - ImageView. The expected bind value is a resource id or a string and
setViewImage(ImageView, int)
orsetViewImage(ImageView, String)
is invoked.
IllegalStateException
is thrown.
一个简单的适配器,映射数据到定义在一个XML文件中的视图。你可以将列表中的数据指定为Maps的ArrayList。ArrayList中的每个条目对应列表中的每一行。Maps中包含每行的数据。你还指定了一个XML文件,它的定义用于视图显示的行,以及从Map中Key映射特定的视图。将数据绑定到视图有两个阶段。首先,如果
SimpleAdapter.ViewBinder
是可用的,则调用
setViewValue(android.view.View, Object, String)
。如果返回值为true,则绑定成功。如果返回值为false,那么下面的视图将按顺序进行:
- 实现可选中的视图(如:CheckBox)希望绑定的值是一个布尔值。
- TextView。希望绑定的值是一个字符串,并且调用
setViewText(TextView, String)
。 - ImageView。希望绑定的值是一个资源ID或者一个字符串,并且调用
setViewImage(ImageView, int)
或setViewImage(ImageView, String)
。
IllegalStateException
异常。
摘要
嵌套类 | |
---|---|
interface | SimpleAdapter.ViewBinder This class can be used by external clients of SimpleAdapter to bind values to views. |
继承常量 |
---|
From interface android.widget.Adapter
|
Public构造方法 | |
---|---|
SimpleAdapter(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to) Constructor |
Public方法 | |
---|---|
int | getCount() How many items are in the data set represented by this Adapter. |
View | getDropDownView(int position, View convertView, ViewGroup parent) Gets a |
Resources.Theme | getDropDownViewTheme() Returns the value previously set by a call to |
Filter | getFilter() Returns a filter that can be used to constrain data with a filtering pattern. |
Object | getItem(int position) Get the data item associated with the specified position in the data set. |
long | getItemId(int position) Get the row id associated with the specified position in the list. |
View | getView(int position, View convertView, ViewGroup parent) Get a View that displays the data at the specified position in the data set. |
SimpleAdapter.ViewBinder | getViewBinder() Returns the |