C
C
Chesterfield252021-10-31 23:48:14
Java
Chesterfield25, 2021-10-31 23:48:14

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);
        }
    }
}


But at the moment I don't need to use RecyclerView, I need to display the user's data in a fragment, what do I need to fix in the above shown code? Or do I not need an adapter at all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Jacen11, 2021-11-01
@Jacen11

Are you confused by extends RecyclerView.Adapter? Naturally not needed. If not a developer, it's better to hire a freelancer. Or sit and study the development, do not answer within one answer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question