Android ListView Usage

Source: Internet
Author: User

    • In Android development, the ListView is a relatively common development component that presents specific content in a list and is adaptive to the length of the data.

    • The display of a list requires three elements:
    • ListView: A view used to display a list;
    • Adapter: An intermediary used to map data to a ListView, an adapter class that uses the adapter pattern in design mode, which is a bridge between the view and the data, providing access to the data, generating a view of each list item,
      Common adapter classes are: Arrayadapter, Simpleadapter, and Simplecursoradapter.
    • Data: Mapped strings, images, or basic components;

    • Common Properties of the ListView:
Properties Description
Android:divider Sub-dividing line
Android:drivideheight Split Line Height
Android:listselector Sub-item Click Effect
Android:scrollbars Slide Bar
    • Common Methods for ListView:
Method Description
Addfooterview (View v) Add a view to the tail of the list
Addheaderview (View v) Add a view to the list header
Setadapter (ListAdapter Adapyer) Setting up the adapter
Setdivider (drawable divider) Set the subkey separator bar
Setdividerheight (int Height) Set the height of the divider bar

Use of the ListView:

Layout of the ListView:

<ListView        android:id="@id/android:list"        android:layout_width="match_parent"        android:layout_height="wrap_content"        />

Android ListView usage

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.