想从 firebase 数据库中检索唯一的卢比值?
want to retrieve the only Rupees value from firebase database?
您可能认为这个 post 是重复的,但请相信我,我已经尝试了所有这些方法,但这不会让我接近解决方案。
我是初学者,目前处于学习阶段。
我只想在文本视图中检索来自 standard 1st
of School no 109
of Gat No 14
的 rupees
值
这是数据库树
这是我的代码。
java
public class Collection extends AppCompatActivity {
TextView ttl;
Button btnshw;
DatabaseReference d2ref;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_collection);ttl = (TextView) findViewById(R.id.texirs);
btnshw = (Button) findViewById(R.id.bshow);
btnshw.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
d2ref = FirebaseDatabase.getInstance().getReference().child("2018-19").child("Gat No 14")
.child("School no 109").child("Standard 1st");
d2ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot dsnap : dataSnapshot.getChildren()) {
Map<String, String> map = (Map)dsnap.getValue();
if(map != null) {
String gat = dataSnapshot.child("Rupees").getValue().toString();
ttl.setText(gat);
Log.d("Tag",gat);
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
});
}
}
请帮忙!!
试试这个:-
d2ref = FirebaseDatabase.getInstance().getReference().child("2018-19").child("Gat No 14")
.child("School no 109").child("Standard 1st");
d2ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String gat = dataSnapshot.child("Rupees").getValue().toString();
// and set tha gat in your textView
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
您可能认为这个 post 是重复的,但请相信我,我已经尝试了所有这些方法,但这不会让我接近解决方案。
我是初学者,目前处于学习阶段。
我只想在文本视图中检索来自 standard 1st
of School no 109
of Gat No 14
rupees
值
这是数据库树
这是我的代码。
java
public class Collection extends AppCompatActivity {
TextView ttl;
Button btnshw;
DatabaseReference d2ref;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_collection);ttl = (TextView) findViewById(R.id.texirs);
btnshw = (Button) findViewById(R.id.bshow);
btnshw.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
d2ref = FirebaseDatabase.getInstance().getReference().child("2018-19").child("Gat No 14")
.child("School no 109").child("Standard 1st");
d2ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot dsnap : dataSnapshot.getChildren()) {
Map<String, String> map = (Map)dsnap.getValue();
if(map != null) {
String gat = dataSnapshot.child("Rupees").getValue().toString();
ttl.setText(gat);
Log.d("Tag",gat);
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
});
}
}
请帮忙!!
试试这个:-
d2ref = FirebaseDatabase.getInstance().getReference().child("2018-19").child("Gat No 14")
.child("School no 109").child("Standard 1st");
d2ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String gat = dataSnapshot.child("Rupees").getValue().toString();
// and set tha gat in your textView
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});