java - how to show data from firebase into a textview -
hi i'm new @ programming , want show data firebase database textview. have written code doesn't work. hope can me
thank you
this code
public void gotoanotheractivity19(view view) { firebaseuser user = firebaseauth.getinstance().getcurrentuser(); assert user != null; final string log_uid = user.getuid(); final string eintrag = eintragtagebuch.gettext().tostring().trim(); intent intent = new intent(this, tagebuch.class); firebasedatabase database = firebasedatabase.getinstance(); databasereference myref = database.getreference("user" + log_uid); myref.child("tagebuch").push().setvalue("ihr eintrag: " + eintrag ); startactivity(intent); eingabeausgeben(); } public void eingabeausgeben() { tagebuchtext = (textview) findviewbyid(r.id.tagebuch_text2); databasereference rootref = firebasedatabase.getinstance().getreference(); firebaseuser user = firebaseauth.getinstance().getcurrentuser(); assert user != null; final string log_uid = user.getuid(); databasereference tagebuchref = rootref.child("user"+log_uid).child("tagebuch"); valueeventlistener eventlistener = new valueeventlistener() { public void ondatachange(datasnapshot datasnapshot) { for(datasnapshot ds : datasnapshot.getchildren()) { string value = ds.getvalue(string.class); log.e("tag", value + ", "); tagebuchtext.settext("deine einträge" + value); } } @override public void oncancelled(databaseerror databaseerror) {} }; tagebuchref.addlistenerforsinglevalueevent(eventlistener); }
Comments
Post a Comment