English 中文(简体)
氯乙烯过滤器清单,视带板块的输入而定
原标题:Android filter listview depending on edittext input with sql statements

我想提一点问题。 我想知道,什么是我能从qlite数据库中收集的我名单观点的最佳方式,我希望视用户在编辑文本中写过信件而对其进行过滤。 我不表示任何守则,因为我只字不提,而且这样说。 我不得不改变Im使用人口数据库的板块说明。

因此,我的问题是,在用户用编辑文字写进信件时,我如何改变我的精彩发言,我如何能够更新我的清单,更新新的数据,并用新的缩略语。

最佳回答

回答您的先前问题,这些答复非常相似:https://stackoverflow.com/questions/8848100/rosid-add-custom- research-bar-in-application/8891 185 p8891 185>

问题回答

我有同样的问题,并解决了如下问题:

//Search text and changed handler
        EditText tbSearch = (EditText)findViewById(R.id.android_searchbox);
        tbSearch.addTextChangedListener(new TextWatcher() {
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            public void afterTextChanged(Editable s) {
                ListView av = getListView();
                SimpleCursorAdapter filterAdapter = (SimpleCursorAdapter)av.getAdapter();
                filterAdapter.getFilter().filter(s.toString());
            }
        });

        entries.setFilterQueryProvider(new FilterQueryProvider() {
            public Cursor runQuery(CharSequence constraint) {
                return mDbHelper.fetchAllEntries(constraint);
            }
        });

With this approach you will need a method similar to FetchAllEntries(string sFilter)

/*
 * Override to return a Cursor over the list of Entries filtered by a
 * constraint
 * 
 * @return Cursor over filtered Entries
 */
public Cursor fetchAllEntries(CharSequence constraint) {

    if (constraint == null || constraint.length() == 0) {
        // Return the full list
        return fetchAllEntries();
    } else {

        String value = "%" + constraint.toString() + "%";

        String[] columns = new String[] { KEY_ROWID, KEY_TITLE,
                KEY_BODY, KEY_USER_PROFICIENCY };

        return mDb.query(DATABASE_TABLE, columns,
                KEY_TITLE + " like ? OR " + KEY_BODY + " like ? ", new String[] { value, value }, null, null,
                KEY_TITLE + " ASC ");

    }
}

这里的表格有两栏(标题、机构)。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签