December 5th, 2011, 05:38 PM
|
#3 (permalink)
|
|
Member
Join Date: Jun 2010
Posts: 363
Device(s): Samsung Galaxy S (international)
Thanks: 72
Thanked 57 Times in 55 Posts
|
this is not search , what you are looking for is filtering
I did the same mistake before too, I'll try to give you some stuff from my code
at first , you'll need to have an ArrayAdapter for your list , let's call it "datasource"
and an EditText which I'll name "searchBox"
you'll also need to have a textWatcher, you can use this
Code:
private TextWatcher filterTextWatcher = new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
datasource.getFilter().filter(s);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
};
and at the end of your onCreate()
Code:
searchBox.addTextChangedListener(filterTextWatcher);
that should do it for you
__________________
if I ever said anything that helped you , the thanks button is where your cursor/finger should head to
|
|
|