package com.songbuqi.skyking.listview;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.SimpleAdapter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MainActivity extends AppCompatActivity {
private ListView listview;
private ArrayAdapter arrayAdapter;
private SimpleAdapter simpleAdapter;
private List<Map<String,Object>> datalist;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listview = (ListView) findViewById(R.id.listview1);
// String[] data={"宋天健是罗铮的爸爸","宋天健是罗铮的爸爸","宋天健是罗铮的爸爸","宋天健是罗铮的爸爸"};
// arrayAdapter =new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,data);
// listview.setAdapter(arrayAdapter);
simpleAdapter = new SimpleAdapter(this,getdata(), R.layout.item, new String[]{"right","home"},new int[]{R.id.right,R.id.home});
listview.setAdapter(simpleAdapter);
}
private List<Map<String,Object>> getdata(){
for(int i=1;i<20;i=i++) {
Map<String,Object> map = new HashMap<String,Object>();
map.put("home",R.drawable.ic2);
map.put("right",R.id.right);
}
return datalist;
}
}