怎么不对,程序进不去了~`
package com.example.lisstviewtest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.os.Build;
public class MainActivity extends Activity {
private ListView listView;
private ArrayAdapter<String> arrayadapter;
private SimpleAdapter simpleadapter;
private List<Map<String, Object>> listdata;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String[] array_data = {"哈哈1","哈哈2","哈哈3","哈哈4","哈哈5"} ;
listView = (ListView) findViewById(R.id.listView);
arrayadapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, array_data);
simpleadapter = new SimpleAdapter(this, getData(), R.layout.item, new String[]{"image","text"}, new int[]{R.id.image,R.id.text});
listView.setAdapter(simpleadapter);
}
public List<Map<String, Object>> getData(){
for(int i=0;i<20;i++){
Map<String,Object> map= new HashMap<String,Object>();
map.put("image", R.drawable.ic_launcher);
map.put("text", "哈哈"+i);
listdata.add(map);
}
return listdata;
}
}