Use of the "Notes" ListView

Source: Internet
Author: User

1.0 ListView Three elements

1.0.1 Creating basic steps

1. Create a ListView component in the layout file and declare the component in the activity.

2. In the activity, create a suitable adapter.

3. Use the Setadapter (Adapter Adapter) of the ListView to set the Adapter to be the ListView.

1.0.2 different adapter, different usages

1.ArrayAdapter

1.1 Creating Arrayadapter

Arrayadapter arrayadapter = new Arrayadapter (Context context,int layout,t[] data);

1.1.1 Parameter Introduction

Context: Contexts

Layout: Layouts Resource ID

Data: A DataSet (that is, the data that will be displayed on each item on the ListView, in the constructor of Arrayadapter, is a generic array)

1.1.2 Using Arrayadapter

You can use Listview.setadapter (arrayadapter).

The 1.1.3 Arrayadapter is a very simple data adapter. Here is a rough introduction.

2.SimpleAdapter

2.1 Creating Simpleadapter

Simpleadapter simpleadapter = new Simpleadapter (Context context,list list,int layout,string[] key,int[] ID);

2.2.1 Parameter Introduction

Context: Contexts

List: Data collection, general use arraylist

Layout:item Layout Resource ID

Key:map inside the corresponding key

Id:layout each component ID (must correspond to key one by one, position relative)

2.2.2 Initialization parameters

List: Use Map.put ("key", corresponding resource ID);

Layout: A custom item layout resource;

Key:new string[]{"Key01", "key02"};

Id:new INT[]{ID01,ID02};

2.2.3 using Simpleadapter

You can use Listview.setadapter (simpleyadapter).

Use of the "Notes" ListView

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.