zoukankan      html  css  js  c++  java
  • Android采用ListView实现数据列表显示2-使用SimpleAdapter进行数据绑定

    Android采用ListView实现数据列表显示2-使用SimpleAdapter进行数据绑定

    和前面的相比需要获得

    1. //获取到集合数据  
    2.         List<Person> persons = service.getScrollData(0, 10);  
    3.         List<HashMap<String, Object>> data = new ArrayList<HashMap<String,Object>>();

    但一般查询出来cursor的情况多一些,下面是cursor转换成List<Person>的例子。

    1. public List<Person> getAllPersons() {  
    2.         String sql = "select * from person";  
    3.         SQLiteDatabase db = helper.getWritableDatabase();  
    4.         List<Person> personList = new ArrayList<Person>();  
    5.         Person personnull;  
    6.         Cursor cursor = db.rawQuery(sql, null);  
    7.         while (cursor.moveToNext()) {  
    8.             personnew Person();  
    9.             person.setId()(cursor.getString(cursor  
    10.                     .getColumnIndex("id")));  
    11.             person.setName()(cursor.getDouble(cursor  
    12.                     .getColumnIndex("name")));  
    13.             person.setPhone()(cursor.getDouble(cursor  
    14.                     .getColumnIndex("phone")));  
    15.             person.setAmount(cursor.getDouble(cursor.getColumnIndex("amount")));
    16.             personList .add(person);  
    17.         }  
    18.         return personList;  
    19.     } 

    有了List<Person>集合数据剩下的可以使用使用SimpleAdapter进行数据绑定显示列表。

  • 相关阅读:
    flask 数据迁移
    docker daemon 配置代理
    dbcm with kubenetes
    curl 访问 k8s
    kubernetes 集群安全配置
    k8s dashboard
    k8s v1.5.8 单节点搭建
    etcd raft library
    split files test
    ubuntu两个python版本共存并切换默认版本
  • 原文地址:https://www.cnblogs.com/harry335/p/4796427.html
Copyright © 2011-2022 走看看