ListView and Baseadapter

Source: Internet
Author: User

  The recent use of the ListView combined with Baseadapter, the two also slowly become familiar with, here to do a small summary.

A ListView is a typical adapter control that derives from Android.widget.AdapterView, and typically consists of three parts that control views, data sources, and adapter objects. The purpose of the adapter object is to construct the list item control and bind the data item to the list item control, Baseadapter is a more common and powerful adapter, the key is the implementation of the GetView () method;

@Override      Public View GetView (int  position, view Convertview, ViewGroup parent) {        //  TODO auto-generated method Stub        returnnull;    }

During the adapter customization process, the developer needs to define the number of list items and determine the data content for each list item, as well as construct a list space object for the list item and bind the corresponding list item data to the list item control.

The adapter is constructed in such a way that when many things in a list item can cause the number of child controls to swell sharply, consume a lot of memory, or even crash. The Android adapter control has an input function convertview in the GetView function at design time to cache the most recent list item space object that has lost visual state . Such as

Convertview is the list item control that is used to cache the lost visual state, which is passed through the GetView function to the developer, and the developer can reuse the control object to rebind the data of the list item object, thus avoiding the overhead of constructing a new list item control. Combining Viewholder will be more efficient (avoid repeating getviewbyid ());

ListView and Baseadapter

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.