开发者

EditText filter run slowly when filter data

My Lis开发者_如何学运维tView have more than 3000 rows. And when I typing on EditText to filter data in my ListView it run slowly. Look at my code here

final TextWatcher textChecker = new TextWatcher() {
    public void afterTextChanged(Editable s) {}

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

    public void onTextChanged(CharSequence s, int start, int before,
                    int count) {

        filterData(search.getText().toString());

    }
};

private void filterData(String textinput){
    mCursor = mHelperData.searchData(textinput);
    startManagingCursor(mCursor);

    String[] from = new String[]{ MyData.KEY_ROWID,
            MyData.KEY_TITLE, MyData.KEY_DESCRIPTION };

    int[] to = new int[]{ R.id.id, R.id.title, R.id.description, R.id.icon };       
    setListAdapter(new MyAdapter(this, R.layout.list_row, mCursor, from, to ));
}

I think retrieve data with Cursor is not a good way here. So, Is there any better way to improve the speech in this case?


Come up with a navigation pattern that does not involve the user having to scroll through or filter 3000 rows.

Scrolling through or filtering 3000 rows would be very annoying on a quad-core desktop with 4GB of RAM, continuous AC power, a 19" LCD, a full-size keyboard, and a standard mouse.

Similarly, no Web site worth mentioning dumps 3000 entries on a user in a single page...and people using Web browsers are still using full size screens, keyboards, and mice in many instances.

Sifting through 3000 rows on a phone is insane. Do not make users do that. For example, divide those 3000 rows into categories, and have the user pick a category first.


Just to add to Marks answer - I recently faced the same problem and came up with tutorial on Androidguys.com which demonstrates how one can code an "endless" list

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜