.xml

<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/sa_1"> </ListView>

.java

package com.hanqi.application3;

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 UI4Activity extends AppCompatActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ui4); ListView sa_1 = (ListView)findViewById(R.id.sa_1);
//准备数据源
List<Map<String,Object>> lm = new ArrayList<Map<String,Object>>(); Map<String, Object> map=new HashMap<String, Object>();
map.put("image",R.drawable.an1);
map.put("name","美食图片01");
map.put("content","看上去很好吃01");
lm.add(map); map=new HashMap<String, Object>();
map.put("image",R.drawable.an2);
map.put("name","美食图片02");
map.put("content","看上去很好吃02");
lm.add(map); map=new HashMap<String, Object>();
map.put("image",R.drawable.an3);
map.put("name","美食图片03");
map.put("content","看上去很好吃03");
lm.add(map);
//1 数据源里key的数组
String[] str={"image","name","content"};
//2 layout文件里子视图的id
int[] viewid = {R.id.iv_2,R.id.tv_1,R.id.tv_2 }; SimpleAdapter sa = new SimpleAdapter(this,lm,R.layout.layout_simple,str,viewid); sa_1.setAdapter(sa);
}
}
layout_simple.xml
<?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="wrap_content"> <ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:src="@drawable/an1"
android:id="@+id/iv_2"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_vertical"
android:layout_marginLeft="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="美食图片"
android:id="@+id/tv_1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="很好吃的样子"
android:id="@+id/tv_2"/> </LinearLayout> </LinearLayout>
 

andorid 列表视图之SimpleAdapter的更多相关文章

  1. andorid 列表视图 ListView 之BaseAdapter

    .xml <?xml version="1.0" encoding="utf-8"?> <ListView xmlns:android=&qu ...

  2. andorid 列表视图 ListView 之ArrayAdapter

    activity_ui3.xml <?xml version="1.0" encoding="utf-8"?> <ListView xmlns ...

  3. 滚动视图、列表视图[ListView、SimpleAdapter类]

    滚动视图 <ScrollView android: layout_width="fill_parent" android: layout_height="fill_ ...

  4. Android应用开发学习之列表视图

    作者:刘昊昱 博客:http://blog.csdn.net/liuhaoyutz 列表视图我们会经常用到,可以通过两种方式来创建列表视图,一种方式是直接使用ListView组件创建,另一种方式是通过 ...

  5. jQuery Mobile 列表视图(带有自动检索)

    输入a: 输入b: jQuery Mobile 列表视图 jQuery Mobile 中的列表视图是标准的 HTML 列表:有序列表 (<ol>) 和无序列表 (<ul>). ...

  6. SharePoint 2013无代码实现列表视图的时间段动态筛选

    本文介绍两种为列表视图设置时间段筛选器的方法.其中,第一个方法用于SharePoint Server,第二个方法同时还能用于SharePoint Foundation. 方法一:日期筛选器Web部件 ...

  7. Sharepoint 2013列表视图和字段权限扩展插件(免费下载)!

    记得2014年春节期间,有博客园的网友通过QQ向我咨询Sharepoint 2013列表视图和字段权限扩展,因为之前他看到我博客介绍Sharepoint 2010列表视图和字段的权限控制扩展使用,问有 ...

  8. Android列表视图(List View)

    Android列表视图(ListView) ListView是一个显示滚动项列表的示视图组(viewgroup),通过使用适配器(Adapter)把这些列表项自动插入到列表中.适配器比如从一个数组或是 ...

  9. Android——列表视图(ListView)

    列表视图是android中最常用的一种视图组件,它以垂直列表的形式列出需要显示的列表项.在android中有两种方法向屏幕中添加列表视图:一种是直接使用ListView组件创建:另外一种是让Activ ...

随机推荐

  1. Android文档 学习目录

    Building Your First App After you've installed the Android SDK, start with this class to learn the b ...

  2. webui-popover 一个轻量级的jquery弹出层插件

    该提示框插件可以和Bootstrap完美结合,但是并不一定需要和Bootstrap一起使用.它支持IE7以上的浏览器. 首先要引入需要的css  js  文件 <link rel="s ...

  3. yii基础控制器安全验证

  4. JVM G1GC参数配置

    https://www.oracle.com/technetwork/articles/java/g1gc-1984535.html         主要这两个参数需要设置下,ParallelGCTh ...

  5. Python 测试

    (1)import doctest doctest.testmod(verbose=True) (2) pip install tests

  6. AssetBundle 策略

    [AssetBundle 策略] 1.Logical Entity Grouping.按逻辑功能分. Examples Bundling all the textures and layout dat ...

  7. MySQL driver for Node

    [MySQL driver for Node] 1.安装 2.一个示例 From this example, you can learn the following: Every method you ...

  8. html开发环境

    标签(空格分隔): 环境 开发环境: 市面上有很多的HTML编辑器可以选择,常见的Hbuild.Sublime Text.Dreamweare都可以用来开发HTML. 当然PyCharm也支持HTML ...

  9. ORM笔记

    ORM工具的唯一作用就是:把对持久化对象的保存.删除.修改等操作,转换成对数据库的操作,而ORM框架则负责转换成对应的SQL(结构化查询语言)操作.(ORM工具可完成对象模型和关系模型直接的相互映射) ...

  10. SpringBoot配置logback

    1.在SpringBoot中已经集成了logback.在pom.xml中加入以下spring-boot-starter依赖,使用默认版本即可: <dependency> <group ...