增加实时日志查询

This commit is contained in:
2026-01-19 14:32:48 +08:00
parent b23045194a
commit 40d41d1afb
7 changed files with 163 additions and 67 deletions
@@ -0,0 +1,30 @@
package com.sw.platecabinet.adapter
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.sw.platecabinet.databinding.ListItemLogInfoBinding
class LogAdapter(var list: MutableList<String>) : RecyclerView.Adapter<LogAdapter.ViewHolder> {
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.binding.tvLogText.text = list[position]
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val binding =
ListItemLogInfoBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return ViewHolder(binding)
}
override fun getItemCount() = list.size
inner class ViewHolder(var binding: ListItemLogInfoBinding) :
RecyclerView.ViewHolder(binding.root)
fun addData(logInfo: String) {
list.add(logInfo)
notifyDataSetChanged()
}
}