Can I get the view holder of item of edittext's text object reference?

时间:2019-04-23 15:12:03

标签: android android-recyclerview

Can I get the view holder of item of edittext's text object reference?

My viewholder...

override fun bind(list: MutableList<Test>, position: Int) {  
   list.get(position).test.get(0).editable = binding.etTest.text //not reference
   val testEdit = binding.root.findViewById(R.id.et_test) as EditText 
   list.get(position).test.get(0).editable = testEdit.text ////not reference
}

when text is changed, list.get(position).test.get(0).editable is not changed..

How can I do this?

1 个答案:

答案 0 :(得分:0)

您需要澄清您的问题,但是我认为您想使用RecyclerView。在这种情况下,您必须使用ViewHolder模式。

ViewHolder负责使您的视图膨胀,并保留对您的EditText或视图中任何内容的引用。然后,在bind()方法中,您可以填充那个/那个EditText