我有$wp_rewrite->rules
,并且可以使用以下代码在SearchView
中进行搜索:
RecyclerView
如您所见,此代码仅在private List<Question> filter(List<Question> models, String query) {
query = query.toLowerCase();
final List<Question> filteredModelList = new ArrayList<>();
for (Question model : models) {
final String text = model.getTitle().toLowerCase();
if (text.contains(query)) {
filteredModelList.add(model);
}
}
return filteredModelList;
}
上进行搜索,因此,有什么方法可以在2个提交的model.getTitle()
和model.getTitle()
中进行搜索?
谢谢。
答案 0 :(得分:0)
尝试以下代码,
private List<Question> filter(List<Question> models, String query) {
query = query.toLowerCase();
final List<Question> filteredModelList = new ArrayList<>();
for (Question model : models) {
final String textTitle = model.getTitle().toLowerCase();
final String textContent = model.getTitle().toLowerCase();
if (textTitle.contains(query) || textContent.contains(query)) {
filteredModelList.add(model);
}
}
return filteredModelList;
}