运行时出问题,但代码也没报什么错,请问有什么错吗?
package com.example.android_fragment;
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.widget.ListView;
import android.widget.SimpleAdapter;
public class ViewFirst extends Activity{
private ListView listView;
private SimpleAdapter simAdapter;
private List<Map<String,Object>>dataList;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.view1);
listView=(ListView) findViewById(R.id.listView1);
simAdapter=new SimpleAdapter(ViewFirst.this, getData(), R.layout.item1,
new String[]{"imageView","textView"},
new int[]{R.id.imageView1,R.id.textView1});
dataList=new ArrayList<Map<String,Object>>();
//加载适配器
listView.setAdapter(simAdapter);
}
//获取数据源 方法
private List<Map<String,Object>> getData() {
for(int i=0;i<20;i++){
Map<String,Object>map=new HashMap<String,Object>();
map.put("imageView", R.drawable.ic_launcher);
map.put("textView","此处应为文字"+i);
dataList.add(map);
}
return dataList;
}
}