Can't pass null arguement for Adapterclass [duplicate]












-1
















This question already has an answer here:




  • What is a NullPointerException, and how do I fix it?

    12 answers




Good day everyone! I have a problem the app crash and it has an error



java.lang.NullPointerException: Can't pass null for argument 'pathString' in child()
at com.google.firebase.database.DatabaseReference.child(Unknown Source:6)
at com.example.jasper.happy_paws.CommentAdapter.getUserInfo(CommentAdapter.java:95)
at com.example.jasper.happy_paws.CommentAdapter.onBindViewHolder(CommentAdapter.java:51)
at com.example.jasper.happy_paws.CommentAdapter.onBindViewHolder(CommentAdapter.java:26)
at android.support.v7.widget.RecyclerView$Adapter


I dont see anyproblem with my adapter here is my code



public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.ViewHolder> {

private Context mContext;
private List<CommentModel>mComment;
private FirebaseUser firebaseUser;

public CommentAdapter(Context mContext, List<CommentModel> mComment) {
this.mContext = mContext;
this.mComment = mComment;
}

@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mContext).inflate(R.layout.comment_items, parent, false);
return new CommentAdapter.ViewHolder(view);

}

@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int i) {
firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
final CommentModel commentModel = mComment.get(i);

holder.comment.setText(commentModel.getComment());
getUserInfo(holder.image_profile,holder.username, commentModel.getUserid());

holder.comment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, Account.class);
intent.putExtra("userid", commentModel.getUserid());
mContext.startActivity(intent);
}
});

holder.image_profile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, Account.class);
intent.putExtra("userid", commentModel.getUserid());
mContext.startActivity(intent);
}
});



}

@Override
public int getItemCount() {
return mComment.size();
}

public class ViewHolder extends RecyclerView.ViewHolder{

public ImageView image_profile;
public TextView username,comment;

public ViewHolder(View itemView) {
super(itemView);

image_profile = itemView.findViewById(R.id.image_profile);
username = itemView.findViewById(R.id.username);
comment = itemView.findViewById(R.id.comment);
}
}
private void getUserInfo(final ImageView imageView, final TextView username, String userid)
{
DatabaseReference reference = FirebaseDatabase.getInstance().getReference().child("User").child(userid);
reference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
UsersHappyPaws usersHappyPaws = dataSnapshot.getValue(UsersHappyPaws.class);
Glide.with(mContext).load(usersHappyPaws.getProfilepic()).into(imageView);
username.setText(usersHappyPaws.getName());
}



@Override
public void onCancelled(@NonNull DatabaseError databaseError) {

}
});
}
}









share|improve this question















marked as duplicate by Doug Stevenson, Peter Haddad, Ken Y-N, Martin Zeitler, Alex Mamo android
Users with the  android badge can single-handedly close android questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 '18 at 8:35


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




















    -1
















    This question already has an answer here:




    • What is a NullPointerException, and how do I fix it?

      12 answers




    Good day everyone! I have a problem the app crash and it has an error



    java.lang.NullPointerException: Can't pass null for argument 'pathString' in child()
    at com.google.firebase.database.DatabaseReference.child(Unknown Source:6)
    at com.example.jasper.happy_paws.CommentAdapter.getUserInfo(CommentAdapter.java:95)
    at com.example.jasper.happy_paws.CommentAdapter.onBindViewHolder(CommentAdapter.java:51)
    at com.example.jasper.happy_paws.CommentAdapter.onBindViewHolder(CommentAdapter.java:26)
    at android.support.v7.widget.RecyclerView$Adapter


    I dont see anyproblem with my adapter here is my code



    public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.ViewHolder> {

    private Context mContext;
    private List<CommentModel>mComment;
    private FirebaseUser firebaseUser;

    public CommentAdapter(Context mContext, List<CommentModel> mComment) {
    this.mContext = mContext;
    this.mComment = mComment;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    View view = LayoutInflater.from(mContext).inflate(R.layout.comment_items, parent, false);
    return new CommentAdapter.ViewHolder(view);

    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int i) {
    firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
    final CommentModel commentModel = mComment.get(i);

    holder.comment.setText(commentModel.getComment());
    getUserInfo(holder.image_profile,holder.username, commentModel.getUserid());

    holder.comment.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    Intent intent = new Intent(mContext, Account.class);
    intent.putExtra("userid", commentModel.getUserid());
    mContext.startActivity(intent);
    }
    });

    holder.image_profile.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    Intent intent = new Intent(mContext, Account.class);
    intent.putExtra("userid", commentModel.getUserid());
    mContext.startActivity(intent);
    }
    });



    }

    @Override
    public int getItemCount() {
    return mComment.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder{

    public ImageView image_profile;
    public TextView username,comment;

    public ViewHolder(View itemView) {
    super(itemView);

    image_profile = itemView.findViewById(R.id.image_profile);
    username = itemView.findViewById(R.id.username);
    comment = itemView.findViewById(R.id.comment);
    }
    }
    private void getUserInfo(final ImageView imageView, final TextView username, String userid)
    {
    DatabaseReference reference = FirebaseDatabase.getInstance().getReference().child("User").child(userid);
    reference.addValueEventListener(new ValueEventListener() {
    @Override
    public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
    UsersHappyPaws usersHappyPaws = dataSnapshot.getValue(UsersHappyPaws.class);
    Glide.with(mContext).load(usersHappyPaws.getProfilepic()).into(imageView);
    username.setText(usersHappyPaws.getName());
    }



    @Override
    public void onCancelled(@NonNull DatabaseError databaseError) {

    }
    });
    }
    }









    share|improve this question















    marked as duplicate by Doug Stevenson, Peter Haddad, Ken Y-N, Martin Zeitler, Alex Mamo android
    Users with the  android badge can single-handedly close android questions as duplicates and reopen them as needed.

    StackExchange.ready(function() {
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function() {
    $hover.showInfoMessage('', {
    messageElement: $msg.clone().show(),
    transient: false,
    position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
    dismissable: false,
    relativeToBody: true
    });
    },
    function() {
    StackExchange.helpers.removeMessages();
    }
    );
    });
    });
    Nov 20 '18 at 8:35


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















      -1












      -1








      -1









      This question already has an answer here:




      • What is a NullPointerException, and how do I fix it?

        12 answers




      Good day everyone! I have a problem the app crash and it has an error



      java.lang.NullPointerException: Can't pass null for argument 'pathString' in child()
      at com.google.firebase.database.DatabaseReference.child(Unknown Source:6)
      at com.example.jasper.happy_paws.CommentAdapter.getUserInfo(CommentAdapter.java:95)
      at com.example.jasper.happy_paws.CommentAdapter.onBindViewHolder(CommentAdapter.java:51)
      at com.example.jasper.happy_paws.CommentAdapter.onBindViewHolder(CommentAdapter.java:26)
      at android.support.v7.widget.RecyclerView$Adapter


      I dont see anyproblem with my adapter here is my code



      public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.ViewHolder> {

      private Context mContext;
      private List<CommentModel>mComment;
      private FirebaseUser firebaseUser;

      public CommentAdapter(Context mContext, List<CommentModel> mComment) {
      this.mContext = mContext;
      this.mComment = mComment;
      }

      @NonNull
      @Override
      public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
      View view = LayoutInflater.from(mContext).inflate(R.layout.comment_items, parent, false);
      return new CommentAdapter.ViewHolder(view);

      }

      @Override
      public void onBindViewHolder(@NonNull ViewHolder holder, int i) {
      firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
      final CommentModel commentModel = mComment.get(i);

      holder.comment.setText(commentModel.getComment());
      getUserInfo(holder.image_profile,holder.username, commentModel.getUserid());

      holder.comment.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      Intent intent = new Intent(mContext, Account.class);
      intent.putExtra("userid", commentModel.getUserid());
      mContext.startActivity(intent);
      }
      });

      holder.image_profile.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      Intent intent = new Intent(mContext, Account.class);
      intent.putExtra("userid", commentModel.getUserid());
      mContext.startActivity(intent);
      }
      });



      }

      @Override
      public int getItemCount() {
      return mComment.size();
      }

      public class ViewHolder extends RecyclerView.ViewHolder{

      public ImageView image_profile;
      public TextView username,comment;

      public ViewHolder(View itemView) {
      super(itemView);

      image_profile = itemView.findViewById(R.id.image_profile);
      username = itemView.findViewById(R.id.username);
      comment = itemView.findViewById(R.id.comment);
      }
      }
      private void getUserInfo(final ImageView imageView, final TextView username, String userid)
      {
      DatabaseReference reference = FirebaseDatabase.getInstance().getReference().child("User").child(userid);
      reference.addValueEventListener(new ValueEventListener() {
      @Override
      public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
      UsersHappyPaws usersHappyPaws = dataSnapshot.getValue(UsersHappyPaws.class);
      Glide.with(mContext).load(usersHappyPaws.getProfilepic()).into(imageView);
      username.setText(usersHappyPaws.getName());
      }



      @Override
      public void onCancelled(@NonNull DatabaseError databaseError) {

      }
      });
      }
      }









      share|improve this question

















      This question already has an answer here:




      • What is a NullPointerException, and how do I fix it?

        12 answers




      Good day everyone! I have a problem the app crash and it has an error



      java.lang.NullPointerException: Can't pass null for argument 'pathString' in child()
      at com.google.firebase.database.DatabaseReference.child(Unknown Source:6)
      at com.example.jasper.happy_paws.CommentAdapter.getUserInfo(CommentAdapter.java:95)
      at com.example.jasper.happy_paws.CommentAdapter.onBindViewHolder(CommentAdapter.java:51)
      at com.example.jasper.happy_paws.CommentAdapter.onBindViewHolder(CommentAdapter.java:26)
      at android.support.v7.widget.RecyclerView$Adapter


      I dont see anyproblem with my adapter here is my code



      public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.ViewHolder> {

      private Context mContext;
      private List<CommentModel>mComment;
      private FirebaseUser firebaseUser;

      public CommentAdapter(Context mContext, List<CommentModel> mComment) {
      this.mContext = mContext;
      this.mComment = mComment;
      }

      @NonNull
      @Override
      public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
      View view = LayoutInflater.from(mContext).inflate(R.layout.comment_items, parent, false);
      return new CommentAdapter.ViewHolder(view);

      }

      @Override
      public void onBindViewHolder(@NonNull ViewHolder holder, int i) {
      firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
      final CommentModel commentModel = mComment.get(i);

      holder.comment.setText(commentModel.getComment());
      getUserInfo(holder.image_profile,holder.username, commentModel.getUserid());

      holder.comment.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      Intent intent = new Intent(mContext, Account.class);
      intent.putExtra("userid", commentModel.getUserid());
      mContext.startActivity(intent);
      }
      });

      holder.image_profile.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      Intent intent = new Intent(mContext, Account.class);
      intent.putExtra("userid", commentModel.getUserid());
      mContext.startActivity(intent);
      }
      });



      }

      @Override
      public int getItemCount() {
      return mComment.size();
      }

      public class ViewHolder extends RecyclerView.ViewHolder{

      public ImageView image_profile;
      public TextView username,comment;

      public ViewHolder(View itemView) {
      super(itemView);

      image_profile = itemView.findViewById(R.id.image_profile);
      username = itemView.findViewById(R.id.username);
      comment = itemView.findViewById(R.id.comment);
      }
      }
      private void getUserInfo(final ImageView imageView, final TextView username, String userid)
      {
      DatabaseReference reference = FirebaseDatabase.getInstance().getReference().child("User").child(userid);
      reference.addValueEventListener(new ValueEventListener() {
      @Override
      public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
      UsersHappyPaws usersHappyPaws = dataSnapshot.getValue(UsersHappyPaws.class);
      Glide.with(mContext).load(usersHappyPaws.getProfilepic()).into(imageView);
      username.setText(usersHappyPaws.getName());
      }



      @Override
      public void onCancelled(@NonNull DatabaseError databaseError) {

      }
      });
      }
      }




      This question already has an answer here:




      • What is a NullPointerException, and how do I fix it?

        12 answers








      android firebase






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 '18 at 7:37









      Nilesh Rathod

      30.6k82956




      30.6k82956










      asked Nov 20 '18 at 7:35









      Jasper OrtizJasper Ortiz

      196




      196




      marked as duplicate by Doug Stevenson, Peter Haddad, Ken Y-N, Martin Zeitler, Alex Mamo android
      Users with the  android badge can single-handedly close android questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 20 '18 at 8:35


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by Doug Stevenson, Peter Haddad, Ken Y-N, Martin Zeitler, Alex Mamo android
      Users with the  android badge can single-handedly close android questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 20 '18 at 8:35


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


























          1 Answer
          1






          active

          oldest

          votes


















          0














          Try this way..
          If getting data code is working then pl change this things.



          get data from firebase take into activity or fragment.



              private List<UsersHappyPaws> pawsList=new ArrayList<>();
          private void getUserInfo(final ImageView imageView, final TextView username, String userid)
          {
          DatabaseReference reference = FirebaseDatabase.getInstance().getReference().child("User").child(userid);
          reference.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
          UsersHappyPaws usersHappyPaws = dataSnapshot.getValue(UsersHappyPaws.class);
          pawsList.add(usersHappyPaws);
          }



          @Override
          public void onCancelled(@NonNull DatabaseError databaseError) {

          }
          });
          }


          make adapter class make constructor add pass data into mange.take one array list into adapter class.



          public CommentAdapter(Context mContext, List<CommentModel> mComment,List<UsersHappyPaws> pawsList) {
          this.mContext = mContext;
          this.mComment = mComment;
          this.pawsList=pawsList;
          }


          after that make object for UsersHappyPaws class and bind data according.






          share|improve this answer
























          • commentModelList = new ArrayList<>(); commentAdapter = new CommentAdapter(this,commentModelList,); recyclerView.setAdapter(commentAdapter); why i have error in this thank you Android team Godbless!

            – Jasper Ortiz
            Nov 20 '18 at 8:05













          • yes thats way to pass your data into adapter.

            – Android Team
            Nov 20 '18 at 8:06











          • I have an error in this line commentAdapter = new CommentAdapter(this,commentModelList); sorry I'm a newbie

            – Jasper Ortiz
            Nov 20 '18 at 8:09











          • check commentAdapter parematers

            – Android Team
            Nov 20 '18 at 8:10











          • thank you it worked Additional question in my other activity when i change the username or other datas of user it is working but it turns to black for a while and the logcat said You cannot start a load for a destroyed activity

            – Jasper Ortiz
            Nov 20 '18 at 9:12


















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Try this way..
          If getting data code is working then pl change this things.



          get data from firebase take into activity or fragment.



              private List<UsersHappyPaws> pawsList=new ArrayList<>();
          private void getUserInfo(final ImageView imageView, final TextView username, String userid)
          {
          DatabaseReference reference = FirebaseDatabase.getInstance().getReference().child("User").child(userid);
          reference.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
          UsersHappyPaws usersHappyPaws = dataSnapshot.getValue(UsersHappyPaws.class);
          pawsList.add(usersHappyPaws);
          }



          @Override
          public void onCancelled(@NonNull DatabaseError databaseError) {

          }
          });
          }


          make adapter class make constructor add pass data into mange.take one array list into adapter class.



          public CommentAdapter(Context mContext, List<CommentModel> mComment,List<UsersHappyPaws> pawsList) {
          this.mContext = mContext;
          this.mComment = mComment;
          this.pawsList=pawsList;
          }


          after that make object for UsersHappyPaws class and bind data according.






          share|improve this answer
























          • commentModelList = new ArrayList<>(); commentAdapter = new CommentAdapter(this,commentModelList,); recyclerView.setAdapter(commentAdapter); why i have error in this thank you Android team Godbless!

            – Jasper Ortiz
            Nov 20 '18 at 8:05













          • yes thats way to pass your data into adapter.

            – Android Team
            Nov 20 '18 at 8:06











          • I have an error in this line commentAdapter = new CommentAdapter(this,commentModelList); sorry I'm a newbie

            – Jasper Ortiz
            Nov 20 '18 at 8:09











          • check commentAdapter parematers

            – Android Team
            Nov 20 '18 at 8:10











          • thank you it worked Additional question in my other activity when i change the username or other datas of user it is working but it turns to black for a while and the logcat said You cannot start a load for a destroyed activity

            – Jasper Ortiz
            Nov 20 '18 at 9:12
















          0














          Try this way..
          If getting data code is working then pl change this things.



          get data from firebase take into activity or fragment.



              private List<UsersHappyPaws> pawsList=new ArrayList<>();
          private void getUserInfo(final ImageView imageView, final TextView username, String userid)
          {
          DatabaseReference reference = FirebaseDatabase.getInstance().getReference().child("User").child(userid);
          reference.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
          UsersHappyPaws usersHappyPaws = dataSnapshot.getValue(UsersHappyPaws.class);
          pawsList.add(usersHappyPaws);
          }



          @Override
          public void onCancelled(@NonNull DatabaseError databaseError) {

          }
          });
          }


          make adapter class make constructor add pass data into mange.take one array list into adapter class.



          public CommentAdapter(Context mContext, List<CommentModel> mComment,List<UsersHappyPaws> pawsList) {
          this.mContext = mContext;
          this.mComment = mComment;
          this.pawsList=pawsList;
          }


          after that make object for UsersHappyPaws class and bind data according.






          share|improve this answer
























          • commentModelList = new ArrayList<>(); commentAdapter = new CommentAdapter(this,commentModelList,); recyclerView.setAdapter(commentAdapter); why i have error in this thank you Android team Godbless!

            – Jasper Ortiz
            Nov 20 '18 at 8:05













          • yes thats way to pass your data into adapter.

            – Android Team
            Nov 20 '18 at 8:06











          • I have an error in this line commentAdapter = new CommentAdapter(this,commentModelList); sorry I'm a newbie

            – Jasper Ortiz
            Nov 20 '18 at 8:09











          • check commentAdapter parematers

            – Android Team
            Nov 20 '18 at 8:10











          • thank you it worked Additional question in my other activity when i change the username or other datas of user it is working but it turns to black for a while and the logcat said You cannot start a load for a destroyed activity

            – Jasper Ortiz
            Nov 20 '18 at 9:12














          0












          0








          0







          Try this way..
          If getting data code is working then pl change this things.



          get data from firebase take into activity or fragment.



              private List<UsersHappyPaws> pawsList=new ArrayList<>();
          private void getUserInfo(final ImageView imageView, final TextView username, String userid)
          {
          DatabaseReference reference = FirebaseDatabase.getInstance().getReference().child("User").child(userid);
          reference.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
          UsersHappyPaws usersHappyPaws = dataSnapshot.getValue(UsersHappyPaws.class);
          pawsList.add(usersHappyPaws);
          }



          @Override
          public void onCancelled(@NonNull DatabaseError databaseError) {

          }
          });
          }


          make adapter class make constructor add pass data into mange.take one array list into adapter class.



          public CommentAdapter(Context mContext, List<CommentModel> mComment,List<UsersHappyPaws> pawsList) {
          this.mContext = mContext;
          this.mComment = mComment;
          this.pawsList=pawsList;
          }


          after that make object for UsersHappyPaws class and bind data according.






          share|improve this answer













          Try this way..
          If getting data code is working then pl change this things.



          get data from firebase take into activity or fragment.



              private List<UsersHappyPaws> pawsList=new ArrayList<>();
          private void getUserInfo(final ImageView imageView, final TextView username, String userid)
          {
          DatabaseReference reference = FirebaseDatabase.getInstance().getReference().child("User").child(userid);
          reference.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
          UsersHappyPaws usersHappyPaws = dataSnapshot.getValue(UsersHappyPaws.class);
          pawsList.add(usersHappyPaws);
          }



          @Override
          public void onCancelled(@NonNull DatabaseError databaseError) {

          }
          });
          }


          make adapter class make constructor add pass data into mange.take one array list into adapter class.



          public CommentAdapter(Context mContext, List<CommentModel> mComment,List<UsersHappyPaws> pawsList) {
          this.mContext = mContext;
          this.mComment = mComment;
          this.pawsList=pawsList;
          }


          after that make object for UsersHappyPaws class and bind data according.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 '18 at 7:44









          Android TeamAndroid Team

          7,54011033




          7,54011033













          • commentModelList = new ArrayList<>(); commentAdapter = new CommentAdapter(this,commentModelList,); recyclerView.setAdapter(commentAdapter); why i have error in this thank you Android team Godbless!

            – Jasper Ortiz
            Nov 20 '18 at 8:05













          • yes thats way to pass your data into adapter.

            – Android Team
            Nov 20 '18 at 8:06











          • I have an error in this line commentAdapter = new CommentAdapter(this,commentModelList); sorry I'm a newbie

            – Jasper Ortiz
            Nov 20 '18 at 8:09











          • check commentAdapter parematers

            – Android Team
            Nov 20 '18 at 8:10











          • thank you it worked Additional question in my other activity when i change the username or other datas of user it is working but it turns to black for a while and the logcat said You cannot start a load for a destroyed activity

            – Jasper Ortiz
            Nov 20 '18 at 9:12



















          • commentModelList = new ArrayList<>(); commentAdapter = new CommentAdapter(this,commentModelList,); recyclerView.setAdapter(commentAdapter); why i have error in this thank you Android team Godbless!

            – Jasper Ortiz
            Nov 20 '18 at 8:05













          • yes thats way to pass your data into adapter.

            – Android Team
            Nov 20 '18 at 8:06











          • I have an error in this line commentAdapter = new CommentAdapter(this,commentModelList); sorry I'm a newbie

            – Jasper Ortiz
            Nov 20 '18 at 8:09











          • check commentAdapter parematers

            – Android Team
            Nov 20 '18 at 8:10











          • thank you it worked Additional question in my other activity when i change the username or other datas of user it is working but it turns to black for a while and the logcat said You cannot start a load for a destroyed activity

            – Jasper Ortiz
            Nov 20 '18 at 9:12

















          commentModelList = new ArrayList<>(); commentAdapter = new CommentAdapter(this,commentModelList,); recyclerView.setAdapter(commentAdapter); why i have error in this thank you Android team Godbless!

          – Jasper Ortiz
          Nov 20 '18 at 8:05







          commentModelList = new ArrayList<>(); commentAdapter = new CommentAdapter(this,commentModelList,); recyclerView.setAdapter(commentAdapter); why i have error in this thank you Android team Godbless!

          – Jasper Ortiz
          Nov 20 '18 at 8:05















          yes thats way to pass your data into adapter.

          – Android Team
          Nov 20 '18 at 8:06





          yes thats way to pass your data into adapter.

          – Android Team
          Nov 20 '18 at 8:06













          I have an error in this line commentAdapter = new CommentAdapter(this,commentModelList); sorry I'm a newbie

          – Jasper Ortiz
          Nov 20 '18 at 8:09





          I have an error in this line commentAdapter = new CommentAdapter(this,commentModelList); sorry I'm a newbie

          – Jasper Ortiz
          Nov 20 '18 at 8:09













          check commentAdapter parematers

          – Android Team
          Nov 20 '18 at 8:10





          check commentAdapter parematers

          – Android Team
          Nov 20 '18 at 8:10













          thank you it worked Additional question in my other activity when i change the username or other datas of user it is working but it turns to black for a while and the logcat said You cannot start a load for a destroyed activity

          – Jasper Ortiz
          Nov 20 '18 at 9:12





          thank you it worked Additional question in my other activity when i change the username or other datas of user it is working but it turns to black for a while and the logcat said You cannot start a load for a destroyed activity

          – Jasper Ortiz
          Nov 20 '18 at 9:12



          Popular posts from this blog

          'app-layout' is not a known element: how to share Component with different Modules

          android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

          WPF add header to Image with URL pettitions [duplicate]