package com.hanqi.testapp22;
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 TestActivity8 extends AppCompatActivity {
ListView lv_1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test8);
lv_1=(ListView)findViewById(R.id.lv_1);
List<Map<String,Object>> lm=new ArrayList<Map<String,Object>>();
Map<String,Object> map=new HashMap<String, Object>();
map.put("img",R.drawable.f1);
map.put("name","美食1");
map.put("content", "美食1的内容");
lm.add(map);
map=new HashMap<String, Object>();
map.put("img", R.drawable.f2);
map.put("name", "美食2");
map.put("content", "美食的内容");
lm.add(map);
map=new HashMap<String, Object>();
map.put("img",R.drawable.f3);
map.put("name","美食3");
map.put("content", "美食3的内容");
lm.add(map);
map=new HashMap<String, Object>();
map.put("img",R.drawable.f4);
map.put("name","美食4");
map.put("content","美食4的内容");
lm.add(map);
map=new HashMap<String, Object>();
map.put("img",R.drawable.f5);
map.put("name","美食5");
map.put("content","美食5的内容");
lm.add(map);
map=new HashMap<String, Object>();
map.put("img",R.drawable.f6);
map.put("name","美食6");
map.put("content","美食6的内容");
lm.add(map);
map=new HashMap<String, Object>();
map.put("img",R.drawable.f7);
map.put("name","美食7");
map.put("content","美食7的内容");
lm.add(map);
map=new HashMap<String, Object>();
map.put("img",R.drawable.f8);
map.put("name","美食8");
map.put("content","美食8的内容");
lm.add(map);
String[] strings={"img","name","content"};
int [] ids={R.id.iv_1,R.id.tv_1,R.id.tv_2};
SimpleAdapter simpleadapter=new SimpleAdapter(this,lm,
R.layout.simple_adapter,strings,ids);
lv_1.setAdapter(simpleadapter);
}
}
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:src="@drawable/f1"
android:id="@+id/iv_1"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:gravity="center_vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="名字=aaa"
android:id="@+id/tv_1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="内容=aaa"
android:id="@+id/tv_2"/>
</LinearLayout>
</LinearLayout>
View Code
![](https://images2015.cnblogs.com/blog/885594/201605/885594-20160518094504873-1849808198.png)