简体   繁体   中英

how to update view in a single item of recycler view

if each item of recycler view has multiple items (Button and textview)

I have interface to handle Recycler's item click , I want upon clicking Recycler view item , be able to update text view and button but from outside of the adapter class ,

how could I achieve this ? thanks

call adapter.notifyItemChanged(position) on the adapter to change only a single object

EDIT: Based on your comment:

you don't need reference of textview. Just update the state of the item in the list at that position. For exmaple, take a boolean, isclicked and mark it as true for position = x

Hadle the text and UI inside the onbindviewholder only based on the isClicked = true or false.

您可以使用AdapterObject.NotifyDataSetChanged而不是在更新列表中的数据之后再次设置适配器。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM