An analysis of Android Recyclerview.

Source: Internet
Author: User

The appearance of Recyclerview can replace the ListView. The use of Recyclerview is very flexible, the division of labor is more explicit, adapter is used to show the view of item, Viewholder keeps each item and handles the interaction.

Below is the layout of item.

Here is the oncreate in activity,

Then the main is the processing in adapter.

In Oncreateviewholder, the main object is to create Viewholder objects, and to pass view views to Viewholder,onbindviewholder is to display the data in the item's view, among other things.

In Viewholder, events are passed through an interface to the activity to handle. Such a clear division of labor, eliminating the ListView in the Convertview.settag and Gettag operations.

An analysis of Android Recyclerview.

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.