unfortunately,Gridview has stopped
打开显示unfortunately,Gridview has stopped怎么回事
打开显示unfortunately,Gridview has stopped怎么回事
2016-04-07
package com.ash.gridview; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.GridView; import android.widget.SimpleAdapter; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class MainActivity extends AppCompatActivity { private GridView gridView; private List<Map<String, Object>> dataList; private int[] icon = {R.drawable.on2, R.drawable.on2, R.drawable.on2 , R.drawable.on2, R.drawable.on2, R.drawable.on2, R.drawable.on2, R.drawable.on2,}; private String[] iconName = {"1", "2", "3", "4", "5", "6", "7", "8"}; private SimpleAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.activity_main); setContentView(R.layout.main); getData(); gridView = (GridView) findViewById(R.id.gridview); dataList = new ArrayList<Map<String, Object>>(); adapter = new SimpleAdapter(this, getData(), R.layout.tem, new String[]{"image", "text"} , new int[]{R.id.image, R.id.text}); gridView.setAdapter(adapter); } private List<Map<String, Object>> getData() { Map<String, Object> map = new HashMap<String, Object>(); for (int i = 0; i < icon.length; i++) { map.put("image", icon[i]); map.put("text", iconName[i]); dataList.add(map); } return dataList; } }
API 16 , Android Studio
请问哪里出问题了?
举报