简体   繁体   English

Listview需要显示数据库中的数据

[英]Listview need to show the data from the database

I am creating dictionary and I need to display the data from the database in the ListView. 我正在创建字典,我需要在ListView中显示数据库中的数据。 Hope someone can help me. 希望可以有人帮帮我。 Here is the code: 这是代码:

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ls = (ListView) findViewById(R.id.mainlist);
    ls.setVisibility(View.VISIBLE);

You will need a custom ArrayAdapter and a method that returns all the values that you need from the database, probably a subclass of the SQLiteOpenHelper class. 您将需要一个自定义的ArrayAdapter和一个从数据库返回您所需的所有值的方法,该方法可能是SQLiteOpenHelper类的子类。 Read about them in detail and eventually you'll know the answer. 详细阅读它们,最终您将知道答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM