只有文字没有图片,有谁知道吗
public class MainActivity extends ActionBarActivity {
private GridView gridview;
private List<Map<String, Object>>dataList;
private int[]jpg={R.drawable.a,R.drawable.b,R.drawable.c,R.drawable.d,R.drawable.e,R.drawable.f,
R.drawable.g,R.drawable.h,};
private String[]text={"1号美女","2号美女","3号美女","4号美女","5号美女","6号美女","7号美女","8号美女"};
private SimpleAdapter simpleadapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gridview=(GridView) findViewById(R.id.gridView1);
/*
* 数据源
* 适配器
* 加载
* 监听
*/
dataList=new ArrayList<Map<String,Object>>();
getData();
simpleadapter=new SimpleAdapter(this, dataList, R.layout.item, new String[]{"jgp","text"}, new int[]{R.id.imageView,R.id.textView});
gridview.setAdapter(simpleadapter);
}
private List<Map<String, Object>> getData() {
for(int i=0;i<8;i++)
{
Map<String, Object>map=new HashMap<String, Object>();
map.put("jpg", jpg[i]);
map.put("text", text[i]);
dataList.add(map);
}
return dataList;
// TODO Auto-generated method stub
}
}