Adapter class:
这是我项目的Adapter类。
public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.MyViewHolder> {
private Context context;
private ArrayList<Product> mProduct;
public ProductAdapter(Context con, ArrayList<Product> list) {
this.context = con;
this.mProduct = list;
}
@Override
public ProductAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(ProductAdapter.MyViewHolder holder, int position) {
Product contact = mProduct.get(position);
holder.name.setText(mProduct.get(position).getName());
holder.pass.setText(mProduct.get(position).getPass());
holder.ward.setText(mProduct.get(position).getWard());
}
这是我的 ValueEvent侦听器:
ValueEvent Listener:
FirebaseDatabase database = FirebaseDatabase.getInstance();
final DatabaseReference ref = database.getReference();
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Toast.makeText(MainActivity.this, "success", Toast.LENGTH_SHORT).show();
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
Product item = snapshot.getValue(Product.class);
mProductList.add(item);
}
productAdapter.notifyDataSetChanged();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
Description:
Objective of this coding: Real time viewing of added members based on the Region & sub-region chosen under a state.
Attached image has the key of each member, their attributes added.
Based on this, the expectation is to list the members, however, the code does not return any error, except blank screen.
我尝试在Recyclerview中检索所有“用户”详细信息,但空白屏幕显示没有任何错误。
I trying for past days. Please help me.
此编码的目标:基于Region&amp ;;实时查看添加的成员。在一个州选择的次区域。
Attached image has the key of each member, their attributes added.
Based on this, the expectation is to list the members, however, the code does not return any error, except blank screen.
我尝试在Recyclerview中检索所有“用户”详细信息,但空白屏幕显示没有任何错误。
I trying for past 4 days. Please help me.
答案 0 :(得分:0)
Thanks Friends....