| | |
| | | import com.example.firstapp.entity.InvitationRecord |
| | | import com.example.firstapp.utils.Log |
| | | |
| | | |
| | | class InvitationRecordAdapter( |
| | | private val context: Context, |
| | | private val data: List<InvitationRecord>, |
| | |
| | | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): InvitationRecordViewHolder { |
| | | val view = LayoutInflater.from(context) |
| | | .inflate(R.layout.activity_invitation_record, parent, false) |
| | | |
| | | return InvitationRecordViewHolder(view) |
| | | } |
| | | override fun onBindViewHolder(holder: InvitationRecordViewHolder, position: Int) { |
| | | val record = data[position % data.size] // 使用取模实现循环 |
| | | holder.recordmessage.text = "${record.userName}" |
| | | holder.recordstatus.text = "${record.status}" |
| | | |
| | | override fun onBindViewHolder(holder: InvitationRecordViewHolder, position: Int) { |
| | | val record = data[position] // 直接使用实际位置 |
| | | holder.recordmessage.text = record.userName |
| | | holder.recordstatus.text = record.status |
| | | } |
| | | |
| | | override fun getItemCount() = if (data.isEmpty()) 0 else Int.MAX_VALUE |
| | | override fun getItemCount() = data.size // 直接返回实际数据大小 |
| | | |
| | | class InvitationRecordViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { |
| | | val recordmessage: TextView = itemView.findViewById(R.id.recordmessage) |