从填充SQLite数据库列表视图 [英] Populating a list view from SQLite Database

查看:152
本文介绍了从填充SQLite数据库列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的机器人。我想要做的就是填充列表视图从我的SQLite database.I知道如何使用数组来做到这一点。有人可以帮我做这个?我知道有一个客场适应以下code和使用它的使用SQLite填充列表视图,但我不知道该怎么做。

I'm new to android. What i'm trying to do is to populate a listview from my sqlite database.I know how to do it using arrays. Can somebody help me doing this? I know there is a away to adapt the following code and using it for populating the listview using SQLite but i don't know how to do it.

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list_item);
        final ListView lt = (ListView)findViewById(R.id.ListView01);
        List<String> w= new ArrayList<String>();
        ArrayAdapter<String> aa;
        w.add("waka");
        w.add("weka");
        w.add("woka");
        aa = new ArrayAdapter<String>(this, R.layout.listW, w);
        lt.setAdapter(aa);
        lt.setTextFilterEnabled(true);
        lt.setOnItemClickListener(new OnItemClickListener() {     
            public void onItemClick(AdapterView<?> a, View v, int position, long id) {
                  final String aux= (String) lt.getItemAtPosition(position);
                  Intent myIntent = new Intent(infoList.this, tabList.class);
                  startActivity(myIntent);
            }});
    }

感谢

推荐答案

要poputaling数据一个ListView最好的方法是使用内容提供商:的 http://developer.android.com/guide/topics/providers/content-providers.html

The best way to poputaling a ListView with data is using Content Providers: http://developer.android.com/guide/topics/providers/content-providers.html

使用内容提供商将您关于数据库打开/关闭操作安全头痛。

Using content providers will you safe headaches regarding open/close operation for the database.

这篇关于从填充SQLite数据库列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆