为什么只显示一个
package com.example.listviewtest3;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class MainActivity extends Activity {
ListView listvew;
ArrayAdapter<String>arr_adapter;
SimpleAdapter sim_adapter;
List<Map<String,Object>> datalist;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listvew=(ListView) findViewById(R.id.listView1);
// arr_adapter=new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_list_item_1, s);
getdata();
sim_adapter=new SimpleAdapter(MainActivity.this, datalist, R.layout.item, new String[]{"image","test"}, new int[]{R.id.imageView1,R.id.textView1});
listvew.setAdapter(sim_adapter);
}
private List< Map<String, Object>> getdata() {
datalist = new ArrayList<Map<String, Object>>();
Map<String, Object>map=new HashMap<String, Object>();
map.put("image", R.drawable.ic_launcher);
map.put("test", "上海");
Map<String, Object>map1=new HashMap<String, Object>();
map.put("image", R.drawable.ic_launcher);
map.put("test", "北京");
Map<String, Object>map2=new HashMap<String, Object>();
map.put("image", R.drawable.ic_launcher);
map.put("test", "广东");
Map<String, Object>map3=new HashMap<String, Object>();
map.put("image", R.drawable.ic_launcher);
map.put("test", "深圳");
datalist.add(map);
datalist.add(map1);
datalist.add(map2);
datalist.add(map3);
// TODO Auto-generated method stub
return datalist;
}
}