适配器调用:
adherenceDetails.hasFixedSize()
adherenceDetails.layoutManager= GridLayoutManager(this@PatientPlanStatus,3)
adherenceDetails.adapter= PatientPlanDetails(this@PatientPlanStatus, patientPlanAdherenceData.data?.get(0)?.adherence!!)
适配器:
class PatientPlanDetails(var mcontext: Context, var patientDatas:ArrayList<AdherencePoJo>): RecyclerView.Adapter<RecyclerView.ViewHolder>() {
override fun getItemCount(): Int {
return patientDatas.size
}
val TAG="PatientPlanDetails"
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): RecyclerView.ViewHolder {
val v = LayoutInflater.from(mcontext).inflate(R.layout.patient_plan_adherence, parent, false)
return Item(v)
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder?, position: Int) {
//Log.i(TAG,"On Bind")
(holder as Item).bindData(patientDatas.get(position),mcontext)
}
class Item(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun bindData(patienData: AdherencePoJo, context: Context) {
val TAG="PatientPlanDetails"
}
}
}
getItemCount() 返回了正确的大小。但只有第一行显示。请查看此图片
卡片的实际高度是正确的,但其中的项目不可见。
在注销时我没有得到任何日志记录。