1、SimpleAdapterActivity

package com.njupt.listview;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class SimpleAdapterActivity1 extends Activity {

	private ListView personLV;
	private List<Person> persons;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
	    
		System.out.println("这时simpleAdapertActivity1");
		personLV = (ListView) findViewById(R.id.personLV);
		
		PersonDao dao = new PersonDao(this);
		
		persons = dao.queryAll(); 
		
		List< Map<String, Object>> data = new ArrayList<Map<String,Object>>();
		
		for(Person p : persons){
			Map<String,Object> map = new HashMap<String, Object>();
			map.put("id", p.getId());
			map.put("name", p.getName());
			map.put("balance", p.getBalance());
			
			data.add(map);
		}
		personLV.setAdapter(new SimpleAdapter(getApplicationContext(),data,R.layout.item,new String[]{"id","name","balance"},new int[]{R.id.idTV,R.id.nameTV,R.id.balanceTV}));
	}

	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}