/**
* RecyclerView的适配器
*/
public class MsgAdapter extends RecyclerView.Adapter<MsgAdapter.ViewHolder> {
private List<Msg> mMsgList;
static class ViewHolder extends RecyclerView.ViewHolder {
LinearLayout leftLayout;
LinearLayout rightLayout;
TextView leftMsg;
TextView rightMsg;
public ViewHolder(View view) {
super(view);
leftLayout = (LinearLayout) view.findViewById(R.id.left_layout);
rightLayout = (LinearLayout) view.findViewById(R.id.right_layout);
leftMsg = (TextView) view.findViewById(R.id.left_msg);
rightMsg = (TextView) view.findViewById(R.id.right_msg);
}
}
public MsgAdapter(List<Msg> msgList) {
mMsgList = msgList;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = Layo
Android聊天界面——RecyclerView的适配器类
最新推荐文章于 2021-04-13 16:49:35 发布
本文详细探讨了Android中用于构建聊天界面的RecyclerView及其适配器类的使用。讲解了如何通过RecyclerView展示列表数据,包括设置布局管理器、自定义适配器以及实现消息气泡效果的方法。
摘要由CSDN通过智能技术生成