Tag: 回收器适配器

再循环查看项目选择

我有一个在kotlin中编码的recyclerview适配器。 我正在努力突出回收商视图的前四项。 我该怎么做? class BodyPartAdapter(var context: Context,var mRecyclerList: RecyclerView,var todayDate:Int, var bodyPartData: ArrayList, var bodyPartSelection: BodyPartSelection, var abc: Int, var firsttime: Boolean, var todayBodypartid: Int, b1: Boolean,var selectedBodypartId: Int, var bodyPartSelected: Boolean): RecyclerView.Adapter() { interface BodyPartSelection { fun onbodyPartClicked(firsttime:Boolean,bodyPart: BodyPart,selected:Boolean) } override fun getItemCount(): Int { return bodyPartData.size } override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): […]

java.lang.IllegalStateException:TextView不能为null(Android / Kotlin)

我有我的Recycler视图下面的ViewHolder类, inner class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { private val dateText = itemView.itemDateSummaryList private val systolicVal = itemView.systolicValue private val diastolicVal = itemView.diastolicValue fun update(listItem: SummaryListItemModel) { Log.i(TAG, “Update method called ” + listItem.date) dateText.text = listItem.date systolicVal.text = listItem.sysVal.toInt().toString() diastolicVal.text = listItem.diasVal.toInt().toString() } } 但是当我运行该应用程序时出现了一个错误dateText.text = listItem.date说, java.lang.IllegalStateException: dateText must not be null at […]

recyclerview notifyDataSetChanged()不工作 – kotlin

回收者视图不会更新后调用notifyDataSetChanged(),我发现了问题,但没有解决方案。 这里是我更改数据的代码 fun changeData(data: List) { // checking the size of the list before logI(“accountLiteList.size before: ” + accountLiteList.size) accountLiteList = data.toMutableList() // checking the size of the list after logI(“accountLiteList.size after: ” + accountLiteList.size) notifyDataSetChanged() } 但getItemCount()仍然返回0 这里是getItemCount()的代码 override fun getItemCount(): Int { logI(“getItemCount: ” + accountLiteList.size) return accountLiteList.size } 这里是日志 AccountsRecyclerAdaptor: accountLiteList.size before: […]