我的代码某处有问题,我无法从字典API检索数据,因此我的应用程序是dic,因此在搜索视图中键入单词,应该检索提交单词的数据,但是我没有得到任何结果
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.settingmenu,menu);
MenuItem item = menu.findItem(R.id.search);
SearchView searchView = (SearchView)item.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
adapter.getFilter().filter(newText);
return true;
}
});
return true;
}
private Filter filertaki = new Filter() {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
ArrayList<modelclass> arrayListiiii = new ArrayList<>();
if(constraint == null || constraint.length() == 0) {
arrayListiiii.addAll(arrayListfull);
} else {
String filerpattern
arrayListiiii.toString().toLowerCase().trim();
for(modelclass item : arrayListiiii) {
if(item.getWord().toLowerCase().contains(filerpattern)) {
arrayListiiii.add(item);
}
}
}
FilterResults results = new FilterResults();
results.values = arrayListiiii;
return results;
}
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
arrayListfull.clear();
arrayListfull.addAll((ArrayList)results.values);
notifyDataSetChanged();
}
};