I have a SearchView
in my ListView
which is in Hindi Language.. When I use the search typing hindi it filters the list fine..
I want to get filtered list when the user searches in English
For Example if the user searches "Mangal" it should filter the list containing मंगल
the following is my MainActivity Class
public class MainActivity extends AppCompatActivity implements SearchView.OnQueryTextListener {
// Declare Variables
ListView list;
ListViewAdapter adapter;
SearchView editsearch;
String[] NameList;
ArrayList<Names> arraylist = new ArrayList<Names>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Generate sample data
NameList = new String[]{"मंगल स्तुति", "भिक्षु स्तुति", "कालू स्तुति",
"तुलसी स्तुति", "महाप्रज्ञ अभिवंदना", "शासन स्तुति", "तपस्या गीत"};
// Locate the ListView in listview_main.xml
list = (ListView) findViewById(R.id.listview);
for (int i = 0; i < NameList.length; i++) {
Names Names = new Names(NameList[i]);
// Binds all strings into an array
arraylist.add(Names);
}
// Pass results to ListViewAdapter Class
adapter = new ListViewAdapter(this, arraylist);
// Binds the Adapter to the ListView
list.setAdapter(adapter);
// Locate the EditText in listview_main.xml
editsearch = (SearchView) findViewById(R.id.search);
editsearch.setOnQueryTextListener(this);
}
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
String text = newText;
adapter.filter(text);
return false;
}
}
i thought of using getQuery
to get the searched text and then compare that which the english versions but that would be very cubersome as there are lot of hindi texts on my ListView..
Also if there is a possibility to set search tags for the items in the List.. i am not sure...
Please help...