1

我有一个由 SQLite 数据库中的一系列数据填充的 ListView。现在我想根据“project_title”列对列表进行排序。据我所知,我们需要使用 ORDER BY。

所以我把它放在这样的查询中:

ListView listView = (ListView) findViewById(R.id.lstText);
        listView.setOnItemClickListener(this);
        listView.setAdapter(new MySimpleCursorAdapter(this, R.layout.listitems,
                managedQuery(Uri.withAppendedPath(Provider.CONTENT_URI,
                        Database.Project.NAME), new String[] { BaseColumns._ID,
                        Database.Project.C_PROJECTTITLE,
                        Database.Project.C_SMALLIMAGE, Database.Project.C_PROJECTDESCRIPTION, Database.Project.C_BIGIMAGE}, "SELECT " + "project_title" 
                       +" FROM "+"Project"+" ORDER BY "+"project_title"+" COLLATE NOCASE ASC", null, null),
                new String[] { Database.Project.C_PROJECTTITLE,
                        Database.Project.C_SMALLIMAGE, Database.Project.C_PROJECTDESCRIPTION}, new int[] {
                        R.id.txt_title, R.id.image, R.id.txt_list_desc}));

但随后 ListView 上没有显示任何内容。我应该如何更正我的 ORDER BY 查询?

4

1 回答 1

2

尝试这样的事情......

String[] all_columns = new String[] { BaseColumns._ID,
                            Database.Project.C_PROJECTTITLE,
                            Database.Project.C_SMALLIMAGE,
                            Database.Project.C_PROJECTDESCRIPTION,
                            Database.Project.C_BIGIMAGE};



 Cursor c = database.query(DatabaseHelper.TABLE, all_columns , whereClause, null, null, null, "project_title asc",null);
于 2012-04-12T12:05:38.933 回答