开发者

How can I reset the SQLite query for my Listview after it has been created?

I have a ListView which is populated by a SQLite query in OnCreate using the following code which then sets up an OnItemClickListener.

ListView menuList = (ListView) findViewById(R.id.ListView_Menu);

String sql = "SELECT EXHIBITORS, ('Stand No. ' || STANDNO) AS STA开发者_StackOverflowNDNO, _ID FROM EXHIBITOR ORDER BY EXHIBITORS";
cursor = myDbHelper.getReadableDatabase().rawQuery(sql, null);

startManagingCursor(cursor);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.menu_item, cursor, FROM, TO);
menuList.setAdapter(adapter);

menuList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

public void onItemClick(AdapterView<?> parent, View itemClicked, int position, long id) {

However, I want to be able to filter the ListView and then amend the query so that the user can reduce the size of the ListView by say requesting all Exhibitors that start with the letter 'A'. How can I do this, I assume by using the above code again but how do I this and still keep the OnItemClickListener working?


CursorAdapter.changeCursor() will allow you to replace your query with one that filters the Exhibitor names.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜