zoukankan      html  css  js  c++  java
  • 构造函数SimpleAdapter()

    作为一个初学者,对于Java 和 Android都是,有很多地方先需要记住的,然后在使用中慢慢体会,理解。现在要记住的就是构造方法SimpleAdapter()的用法。看文档介绍如下:

    public SimpleAdapter (Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to)

    Since: API Level 1

    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.

    Context :一般使用this。

    data:是个列表,这个列表中包含的应该是Map,在代码中,可以如下使用:

          List<Map<String,Object>> data = new ArrayList<Map<String,Object>>();

         Map<String,Object> map = new HashMap<String,Object>();

        map.put(...);

       data.add(map);

    这样就可以使用这个data作为参数了。

    resource:是用来填充ListView的布局文件,比如我们可以在item.xml定义如何填充ListView的一项,其实Listview中的每一项都是这么填充。

    还要注意最后两个参数是String[ ],int[ ]是数组。

  • 相关阅读:
    php 三级连动及 php+ajax的调试方法
    ajax传值 乱码问题
    ajax传值给php
    php连接mssql pdo
    语法正确的情况下报错的原因
    Mina传递对象
    Mina小例子
    基于MINA构建简单高性能的NIO应用
    点与不规则图形关系判断
    Postman----基础使用篇(没有接口文档的情况下如何着手做接口测试)
  • 原文地址:https://www.cnblogs.com/haiming/p/2631303.html
Copyright © 2011-2022 走看看