sqlite查询结果在listview中展示 sqlite查询结果在listview中展示的实现

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

sqlite查询结果在listview中展示 sqlite查询结果在listview中展示的实现

  2021-03-24 我要评论
想了解sqlite查询结果在listview中展示的实现的相关内容吗,在本文为您仔细讲解sqlite查询结果在listview中展示的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:sqlite,listview,下面大家一起来学习吧。

1、获取db实例

SQLiteDatabase db=dbhelper.getWritableDatabase(); 

2、Cursord对象获取查询结构

Cursor cursor=db.rawQuery("select * from good where number>3",null); 

3、新建SimplecursorAdapter对象

SimpleCursorAdapter cursorAdapter=new SimpleCursorAdapter(this, R.layout.golist_item, cursor, new String[]{"_id","name", "price","number"},new int[]{R.id.textView2,R.id.textView3,R.id.textView4,R.id.textView1},CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); 

simplecusoradapter的构造方法有6个参数(上下文环境,listview布局文件,游标,列名(new string[]{}),显示内容(new int[]{}),flag设置监听)

4、setadapter(cursorAdapter);

以上这篇sqlite查询结果在listview中展示的实现就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们