在android开发文档中
-
public SimpleAdapter(Context context, List<? extends Map<String,?>> data, int resource, String[] from, int[] to)
Constructor-
Parameters:
-
context- The context where the View associated with this SimpleAdapter is running -
data- A List of Maps. Each entry in the List corresponds to one row in the list. The Maps contain the data for each row, and should include all the entries specified in "from" -
resource- Resource identifier of a view layout that defines the views for this list item. The layout file should include at least those named views defined in "to" -
from- A list of column names that will be added to the Map associated with each item. -
to- The views that should display column in the "from" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the from parameter.
-
data:map的集合。List中每一个entry都对应于list的每一行。map集合包含了每一列的数据,应该至少包含在"from"中每一列名称对应的entry
resource:list中每一项的展示资源layout.layout资源应该至少包含在to中定义的资源
from:list的每一项和一个map对象做关联。from为map当中每一列的名称
to:from参数中以列展示的view列表。都应该是TextView.list当中前N个view值为from参数当中的前N个值(通过它和xml结合可定义好每一项中每一列的位置信息)
实际情况,to中每一个view对应的文字或图片,先在from的相应位置找到字符串key。然后去map中查找key对应的字符串值或者图片。
ArrayAdapter
-
public ArrayAdapter(Context context, int resource, int textViewResourceId, T[] objects)
Constructor-
Parameters:
-
context- The current context. -
resource- The resource ID for a layout file containing a layout to use when instantiating views. -
textViewResourceId- The id of the TextView within the layout resource to be populated -
objects- The objects to represent in the ListView.
-
resource.资源xml
textViewResourceId:布局中TextView的id.该textview被objects中的内容填充
objects-listview要展示的信息
本文详细解析了Android开发中SimpleAdapter与ArrayAdapter的构造函数参数及其实际应用,帮助开发者掌握如何高效地使用这些适配器来展示数据。
515

被折叠的 条评论
为什么被折叠?



