我正在处理一个android项目。我的情况是我已经可以在Firebase数据库中搜索search_name值,但是我想搜索数据库中的所有相对值
例如:已经搜索了“ search_name”,但现在我想 跟随孩子的search_category,search_description,search_fabric
这是我的数据库结构
这是我的代码:
DatabaseReference reference = FirebaseDatabase.getInstance().getReference().child("Products");
FirebaseRecyclerOptions<Products> options = new FirebaseRecyclerOptions.Builder<Products>()
.setQuery(reference.orderByChild("search_name").startAt(SeachInputText).endAt(SeachInputText+"\uf8ff"), Products.class)
.build();
FirebaseRecyclerAdapter<Products, ProductViewHolder> adapter =
new FirebaseRecyclerAdapter<Products, ProductViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull ProductViewHolder holder, int position, @NonNull final Products model)
{
holder.jProduct_name.setText(model.getName());
holder.jProduct_price.setText("Price = ₹" + model.getPrice());
holder.jAvail_size.setText(model.getAvailable_size());
Picasso.get().load(model.getImage()).into(holder.jProduct_image);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
Intent intent=new Intent(SearchProductsActivity.this,ProductDetailsActivity.class);
intent.putExtra("pid",model.getPid());
startActivity(intent);
finish();
}
});}
@NonNull
@Override
public ProductViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i)
{
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.product_items_layout, parent, false);
ProductViewHolder holder = new ProductViewHolder(view);
return holder;
}
};
jList.setAdapter(adapter);
adapter.startListening();
}