Answer the question
In order to leave comments, you need to log in
Is it mandatory to use RecyclerView.Adapter inheritance?
I had a project in which I displayed data from the firebase database in RecyclerView
I took the adapter example from this project
public class UserProfileAdapter extends RecyclerView.Adapter<UserProfileAdapter.UserViewHolder> {
ProfileFragment context;
ArrayList<User> list;
public UserProfileAdapter (ProfileFragment context, ArrayList<User> list) {
this.context = context;
this.list = list;
}
@NonNull
@Override
public UserViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return null;
}
@Override
public void onBindViewHolder(@NonNull UserViewHolder holder, int position) {
User user = list.get(position);
holder.name.setText(user.getName());
holder.email.setText(user.getEmail());
holder.password.setText(user.getPass());
holder.pv.setText((int) user.getPv());
}
@Override
public int getItemCount() {
return list.size();
}
public static class UserViewHolder extends RecyclerView.ViewHolder {
TextView name, email, password, pv;
public UserViewHolder(@NonNull View itemView) {
super(itemView);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question