I have a problem with string comparison. For example, there is this string:
\"hello world i am from heaven\"
I want to search if this strin
I got the solution finally.
public void onTextChanged(CharSequence s, int start, int before, int count) {
ArrayList> arrayTemplist = new ArrayList>();
String searchString = mEditText.getText().toString();
if(searchString.equals("")){new DownloadJSON().execute();}
else{
for (int i = 0; i < arraylist.size(); i++) {
String currentString = arraylist.get(i).get(MainActivity.COUNTRY);
if (searchString.toLowerCase().contains(currentString.toLowerCase())) {
//pass the character-sequence instead of currentstring
arrayTemplist.add(arraylist.get(i));
}
}
}
adapter = new ListViewAdapter(MainActivity.this, arrayTemplist);
listview.setAdapter(adapter);
}
});
}
Replace the above code with this one:
public void onTextChanged(CharSequence s, int start, int before, int count) {
ArrayList> arrayTemplist = new ArrayList>();
String searchString = mEditText.getText().toString();
if(searchString.equals("")){new DownloadJSON().execute();}
else{
for (int i = 0; i < arraylist.size(); i++) {
String currentString = arraylist.get(i).get(MainActivity.COUNTRY);
if (currentString.toLowerCase().contains(searchString.toLowerCase())) {
//pass the character-sequence instead of currentstring
arrayTemplist.add(arraylist.get(i));
}
}
}
adapter = new ListViewAdapter(MainActivity.this, arrayTemplist);
listview.setAdapter(adapter);
}
});