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