增加实时日志查询
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user