package com.hanqi.testapp2; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; 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 TestActivity7 extends AppCompatActivity { ListView lv_2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test7); lv_2=(ListView)findViewById(R.id.lv_2); List<Map<String,Object>> lm=new ArrayList<Map<String, Object>>(); Map<String,Object> map = new HashMap<String,Object>(); map.put("p7",R.drawable.p7); map.put("name","美食1"); map.put("content", "美食1的介绍"); lm.add(map); map = new HashMap<String,Object>(); map.put("p7",R.drawable.p7); map.put("name","美食2"); map.put("content", "美食2的介绍"); lm.add(map); String str[]={"p7","name","content"}; int []ids={R.id.lv_3,R.id.tv_7,R.id.tv_8}; SimpleAdapter simpleAdapter=new SimpleAdapter(this,lm,R.layout.simple_adapter,str,ids); lv_2.setAdapter(simpleAdapter); } }