【发布时间】:2021-04-15 05:55:24
【问题描述】:
如何解决此错误我正在尝试解决此错误但无法解决此错误我正在从适配器传递 ID 并想在付费活动中检索它请指导如何解决我是初学者请不要标记它重复
//Adapter
Intent intent=new Intent(holder.itemView.getContext(),PayfeeActivity.class);
intent.putExtra("id",id);
holder.itemView.getContext().startActivity(intent);
//PayfeeActivity
id=getIntent().getStringExtra("id");
private void loadsdetail() {
DatabaseReference ref= FirebaseDatabase.getInstance().getReference("Users");
ref.child("Students").child(id).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot ds) {
// for(DataSnapshot ds:snapshot.getChildren())
// {
// String Nam=""+ds.child("name").getValue();
// String accounttype=""+ds.child("accounttype").getValue();
// String shopProfile=""+ds.child("sprofiles").getValue();
// String Email=""+ds.child("email").getValue();
// String Shopaddress=""+ds.child("address").getValue();
Sfphon=""+ds.child("fatherphon").getValue();
// shopnametv.setText(Shopname);
phon.setText(Sfphon);
// emailtv.setText(Email);
//// addresstv.setText(Shopaddress);
try{
// Picasso.get().load(shopProfile).placeholder(R.drawable.ic_store_gray).into(sprofile);
}catch (Exception e)
{
// sprofile.setImageResource(R.drawable.ic_store_gray);
}
// }
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
【问题讨论】:
-
当你运行这段代码时你得到了什么??
-
不能在 child() 中为参数 'pathString' 传递 null
-
你确定“id”不为空吗?
-
最好将结构包含为 text,而不是链接和图像。这样,如果答案中需要它们,可以复制和粘贴它们。要获取您的 Firebase 结构,请使用 Firebase 控制台->导出 JSON,然后复制并粘贴您的结构的 sn-p。另外,请用您已完成的故障排除更新问题。您是否逐行浏览了代码,看看哪一行不起作用以及该行之前的变量是什么?
标签: java android database firebase firebase-authentication