parent
3129d3bf5a
commit
55fd98e2fa
@ -0,0 +1,68 @@
|
|||||||
|
package com.example.leudaemialikeme.Adapter;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.example.leudaemialikeme.Model.Msg;
|
||||||
|
import com.example.leudaemialikeme.R;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MsgAdapter extends RecyclerView.Adapter<MsgAdapter.ViewHolder> {
|
||||||
|
private List<Msg> msgList;
|
||||||
|
|
||||||
|
static class ViewHolder extends RecyclerView.ViewHolder{
|
||||||
|
ImageView portrait;
|
||||||
|
TextView nickname;
|
||||||
|
TextView introduction;
|
||||||
|
LinearLayout linear_msg;
|
||||||
|
public ViewHolder(View view){
|
||||||
|
super(view);
|
||||||
|
portrait = (ImageView)view.findViewById(R.id.img_portrait);
|
||||||
|
nickname = (TextView)view.findViewById(R.id.text_nickname);
|
||||||
|
introduction = (TextView)view.findViewById(R.id.text_introduction);
|
||||||
|
linear_msg = (LinearLayout)view.findViewById(R.id.linear_msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MsgAdapter(List<Msg> msgList) {
|
||||||
|
this.msgList = msgList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public MsgAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.pivate_msg_item,parent,false);
|
||||||
|
MsgAdapter.ViewHolder holder=new MsgAdapter.ViewHolder(view);
|
||||||
|
holder.linear_msg.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
////////////////////////////////////////////////////
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return holder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull MsgAdapter.ViewHolder holder, int position) {
|
||||||
|
Msg msg = msgList.get(position);
|
||||||
|
holder.portrait.setImageResource(msg.getPortraitID());
|
||||||
|
holder.introduction.setText(String.valueOf(msg.getIntroduction()));
|
||||||
|
holder.nickname.setText(msg.getNickname());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return msgList.size();
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.leudaemialikeme;
|
package com.example.leudaemialikeme.Model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.leudaemialikeme;
|
package com.example.leudaemialikeme.Model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.leudaemialikeme;
|
package com.example.leudaemialikeme.Model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.example.leudaemialikeme.Model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Msg implements Serializable {
|
||||||
|
private int portraitID;
|
||||||
|
private String nickname;
|
||||||
|
private String introduction;
|
||||||
|
|
||||||
|
public Msg(int portraitID, String nickname, String introduction) {
|
||||||
|
this.portraitID = portraitID;
|
||||||
|
this.nickname = nickname;
|
||||||
|
this.introduction = introduction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPortraitID(int portraitID) {
|
||||||
|
this.portraitID = portraitID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNickname(String nickname) {
|
||||||
|
this.nickname = nickname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIntroduction(String introduction) {
|
||||||
|
this.introduction = introduction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPortraitID() {
|
||||||
|
return portraitID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNickname() {
|
||||||
|
return nickname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIntroduction() {
|
||||||
|
return introduction;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.leudaemialikeme;
|
package com.example.leudaemialikeme.Model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.leudaemialikeme;
|
package com.example.leudaemialikeme.Model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.example.leudaemialikeme;
|
package com.example.leudaemialikeme.Model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
Loading…
Reference in new issue