0
アダプタ内でaddItem()メソッドが呼び出されましたMainAcivityから呼び出すメソッドがあります。アダプタ内部でメソッドを呼び出すクラス
public class MessageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final int VIEW_TYPE_FIRST = 0;
private static final int VIEW_TYPE_SECOND = 1;
List<Message> mList;
Context context;
LayoutInflater inflater;
public MessageAdapter(Context context, List<Message> mList) {
this.context = context;
this.mList = mList;
this.inflater = LayoutInflater.from(context);
}
public void addItem(Message item) {
mList.add(mList.size()+1,item);
notifyItemInserted(mList.size()+1);
}