开发者

auto search in listview

I created a list view which extends ListActivity and I have a search field at the top of the page

but I don't know how to write it 开发者_JAVA技巧, I want a search like search contact (type just only 1 char and listview will change, don't have to press any button)

please give me some example code

thanks


I think you should see this


If you are currently using a CursorAdapter to display the List, than you can create a custom CursorAdapter which does filtering automatically as you type keys. The following webpage provides an excellent example of this: http://thinkandroid.wordpress.com/2010/01/11/custom-cursoradapters/

Good luck!


Create a AutoCompleteTextView in your Layout,then put this in your class file,

AutoCompleteTextView txtPhoneNo = (AutoCompleteTextView) findViewById(R.id.txtPhoneNo);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line, name_Val);
txtPhoneNo.setAdapter(adapter);

where name_Val is the String Array that contains "DATA"

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜