简体   繁体   中英

How to display data in textviews using firebase/android-studio?

I have a list of data on firebase real-time database and i would like to display this data in textview at my android studio user activity. what should i do to dispaly the currently logged user data?

my database:

我的数据库

this is my user profile activity:

这是我的用户个人资料活动

This can be done by adding event listener to your firebase ref. Sorry i couldnt see your images so ill just give you an example

FirebaseDatabase database = FirebaseDatabase.getInstance();
threadRef = database.getReference("Thread")
threadRef.orderByChild("time").addValueEventListener(threadListener);

ValueEventListener threadListener = new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        for (DataSnapshot messageThread : dataSnapshot.getChildren()) {
            String time = (String) messageThread.child("time").getValue();
            mTextViewer.setText(time);
            break;
        }
    }

    @Override
    public void onCancelled(DatabaseError error) {}
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM