Having problems with filtering custom Listview through customAdapter in Android?


Instead of creating a custom filter to filter a Listview through customAdapter in Android,
Try this…
You can just scroll down to the desired view in the Listview …

Programmitically scrolling to the desired index in a Listview:

String keyword=”yourkeyword”; //This is used for searching
int offset;
offest=scrollToposition(keyword);
Listvew.setSelection(offest);

public int scrollTopostion(String key) {
if ((key != null) && (mystudentlist != null)) { //mystudentlist is the list containing your data
int length = mystudentlist.size();
int i = 0;
while (i < length) {
Listpop item = mystudentlist.get(i); //Listpop  here is the custom list 
String tt = item.getStudentname();
if (tt.toLowerCase().startsWith(key))
return i;
i++;
}
}
return 0;
}

Enjoy!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s