1. Are you ready for the Galaxy S20? Here is everything we know so far!

currently i have been using these types of codes and i am using setter and getter method from module

Discussion in 'Android Development' started by Vora Ravi, Mar 2, 2019.

  1. Vora Ravi

    Vora Ravi Lurker
    Thread Starter

    Code (Text):
    1.  
    2. private DatabaseReference PostRef;
    3.        query sortPost=PostRef;
    4.        enter code hereFirebaseRecyclerOptions<Post> options=new FirebaseRecyclerOptions.Builder<Post>().setQuery(sortPost,Post.class).build();
    5.    [USER=1021285]@override[/USER]
    6.                protected void onBindViewHolder(@NonNull  PostsViewHolder holder, int position, @NonNull final Post model)
    7.                {
    8.                    final String PostKey=getRef(position).getKey();//get key by this line
    9.  
    10.                    PostRef.addValueEventListener(new ValueEventListener()
    11.                    {
    12.                        [USER=1021285]@override[/USER]
    13.                        public void onDataChange(@NonNull DataSnapshot dataSnapshot)
    14.                        {
    15.                            uidOfPostUser= dataSnapshot.child(PostKey).child("uid").getValue().toString();
    16.                        }
    17.  
    18.                        [USER=1021285]@override[/USER]
    19.                        public void onCancelled(@NonNull DatabaseError databaseError) {
    20.  
    21.                        }
    22.                    });
    23.  
    24.                    holder.username.setText(model.getFullname());
    25.  
     

    Attached Files:

    • 1.png
      1.png
      File size:
      13.1 KB
      Views:
      30


    #1 Vora Ravi, Mar 2, 2019
    Last edited by a moderator: Mar 2, 2019

    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...