求大牛帮忙看看 实在找不出错误 程序打不开 直接崩溃
package com.example.yinhao.adapterdemo;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.ListView;
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 ListView listView;
private SimpleAdapter simpleAdapter;
private List<Map<String, Object>> datalist;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
listView = (ListView) findViewById(R.id.listView);
simpleAdapter = new SimpleAdapter(this,getdata(),R.layout.item,new String[]{"pic","text"},new int[]{R.id.pic,R.id.text});
datalist = new ArrayList<Map<String,Object>>();
listView.setAdapter(simpleAdapter);
}
private List<Map<String, Object>> getdata(){
for (int i = 0;i<20;i++){
Map<String,Object> map = new HashMap<String,Object>();
map.put("pic",R.mipmap.ic_launcher);
map.put("text","幕课"+i);
datalist.add(map);
}
return datalist;
}
}