gpt4 book ai didi

带有 Firebase RecyclerView 的 Android 搜索 View 不显示数据

转载 作者:行者123 更新时间:2023-11-29 01:06:58 25 4
gpt4 key购买 nike

我可以通过 RecyclerView 将数据从 Firebase 检索到 App。但是,当我尝试添加搜索 View 时,它不起作用。

 @Override
public boolean onCreateOptionsMenu(Menu menu) {

getMenuInflater().inflate(R.menu.menu_search, menu);
final SearchView searchView =(SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menusearch));
SearchManager searchManager =(SearchManager) getSystemService(SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName());
//searchView.setSubmitButtonEnabled(true);

searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}

@Override
public boolean onQueryTextChange(String newText) {
//SearchText.setText(newText);
Query Q = mDatabase.child("Recipees").orderByChild("cusine").startAt(newText).endAt("");
FirebaseRecyclerAdapter<ImageRetrieve, BlogViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<ImageRetrieve, BlogViewHolder>(

ImageRetrieve.class,
R.layout.recipe_row,
BlogViewHolder.class,
Q

) {
@Override
protected void populateViewHolder(BlogViewHolder viewHolder, ImageRetrieve model, int position) {

viewHolder.setCusine(model.getCusine());
viewHolder.setCatagory(model.getCatagory());
viewHolder.setRecipe(model.getRecipe());
viewHolder.setUrl(getApplicationContext(), model.getUrl());

}
};

mRecipeList.setAdapter(firebaseRecyclerAdapter);



return false;
}


});
return true;
}

最佳答案

试试这个可能会有帮助:

Query Q = mDatabase.child("Recipees").orderByChild("cusine").startAt(newText).endAt(newText+"\uf8ff");

关于带有 Firebase RecyclerView 的 Android 搜索 View 不显示数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46175493/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com