I have a ListView
populated by String[]
. I have an EditText
to filter the listview and search. The thing is that when i search in English and the Strings are in English everything is fine, but when i translate the Strings in other language(e.g. Greek) the filter does not work.
My code:
public class CategoryActivity extends ActionBarActivity {
private ArrayAdapter<String> adapter;
private ListView lv;
private String[] myItems;
private EditText et;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_category);
lv = (ListView)findViewById(R.id.categoryList);
myItems = getIntent().getStringArrayExtra("items");
adapter = new ArrayAdapter<String>(CategoryActivity.this, android.R.layout.simple_list_item_1, myItems);
lv.setAdapter(adapter);
et = (EditText)findViewById(R.id.filterText);
et.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
CategoryActivity.this.adapter.getFilter().filter(s);
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
}
The myItems String[] is populated with Strings(in Greek).
Any help?? Thanks in advance!!
It does not have to do with the language. If you Strings are written in Greek and your keyboard has the Greek Language then you should be able to filter the listView
in Greek and so on.
Hope it helps!!!