老师能帮忙看看我自己学着写的这个SimpleAdapter的例子哪里出问题了么,将这个程序部署到模拟器后直接闪退了,谢谢
public class MainActivity extends Activity implements OnItemSelectedListener{ private TextView textView; private Spinner spinner; private SimpleAdapter sim_adapter; private List<Map<String, Object>>dataList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView = (TextView) findViewById(R.id.textView); spinner = (Spinner) findViewById(R.id.spinner); textView.setText("您选择的是:北京"); dataList = new ArrayList<Map<String,Object>>(); sim_adapter = new SimpleAdapter(this, getData(), R.layout.item, new String[]{"image", "text"}, new int[]{R.id.image, R.id.text}); sim_adapter.setDropDownViewResource(R.layout.item); spinner.setAdapter(sim_adapter); spinner.setOnItemSelectedListener(this); } private List<Map<String, Object>> getData() { Map<String, Object>map1 = new HashMap<String, Object>(); map1.put("image", R.drawable.ic_launcher); map1.put("text", "北京"); Map<String, Object>map2 = new HashMap<String, Object>(); map2.put("image", R.drawable.ic_launcher); map2.put("text", "上海"); Map<String, Object>map3 = new HashMap<String, Object>(); map3.put("image", R.drawable.ic_launcher); map3.put("text", "广州"); Map<String, Object>map4 = new HashMap<String, Object>(); map4.put("image", R.drawable.ic_launcher); map4.put("text", "深圳"); dataList.add(map1); dataList.add(map2); dataList.add(map3); dataList.add(map4); return dataList; } @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { String cityName = (String) sim_adapter.getItem(arg2); textView.setText("您选择的是:"+cityName); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }