Newer
Older
NemophilaClient / app / src / main / java / com / example / nemophila / FriendActivityAdapter.java
package com.example.nemophila;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class FriendActivityAdapter extends RecyclerView.Adapter<FriendsViewHolder> {
    private List<FriendDataModel> list;

    public FriendActivityAdapter(List<FriendDataModel> list) {
        this.list = list;
    }

    public void setList(List<FriendDataModel> list) {
        this.list = list;
    }

    @NonNull
    @Override
    public FriendsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int ViewType) {
        View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_friends_activity, parent,false);
        FriendsViewHolder vh = new FriendsViewHolder(inflate);
        return vh;
    }

    @Override
    public void onBindViewHolder(@NonNull FriendsViewHolder holder, int position) {
        // 後からアイコンの登録をできるようにする
        holder.nameView.setText(list.get(position).getName());
    }

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