Recyclerview.adapter, watch out.

Source: Internet
Author: User

The recent customizations show different item type Recyclerview, and the selected item is labeled with the status checked, so rewrite recyclerview.adapter to implement;

In the process, there are some problems that need to be noted here:

1, by overriding the Getitemviewtype method class setting item displays different types of holdview; in Oncreateviewholder method, different holdview are displayed according to different types ;

2. When overriding the Oncreateviewholder method, the definition of the attached event, and if the exception is defined in the overriding Onbindviewholder method, it will affect the efficiency of each refresh;

3, when the status of the selected item is updated, if you only mark the status of the currently selected item at a time, you can use the variable to record the current Nowselectindex, and then, through the list of managed LayoutManager to determine

Whether the previous selected item is within the currently displayed item range, and if so, refreshes the list with notifyitemchanged (Nowselectindex) or other notify methods and updates the Nowselectindex

The value of this method implements updating the code for the selected item state is placed in the implementation of the Onbindviewholder method.

Above is a personal opinion, hope Big S pass by when pointing <.>

Recyclerview.adapter, watch out.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.