andorid 列表视图之SimpleAdapter
.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的更多相关文章
- andorid 列表视图 ListView 之BaseAdapter
.xml <?xml version="1.0" encoding="utf-8"?> <ListView xmlns:android=&qu ...
- andorid 列表视图 ListView 之ArrayAdapter
activity_ui3.xml <?xml version="1.0" encoding="utf-8"?> <ListView xmlns ...
- 滚动视图、列表视图[ListView、SimpleAdapter类]
滚动视图 <ScrollView android: layout_width="fill_parent" android: layout_height="fill_ ...
- Android应用开发学习之列表视图
作者:刘昊昱 博客:http://blog.csdn.net/liuhaoyutz 列表视图我们会经常用到,可以通过两种方式来创建列表视图,一种方式是直接使用ListView组件创建,另一种方式是通过 ...
- jQuery Mobile 列表视图(带有自动检索)
输入a: 输入b: jQuery Mobile 列表视图 jQuery Mobile 中的列表视图是标准的 HTML 列表:有序列表 (<ol>) 和无序列表 (<ul>). ...
- SharePoint 2013无代码实现列表视图的时间段动态筛选
本文介绍两种为列表视图设置时间段筛选器的方法.其中,第一个方法用于SharePoint Server,第二个方法同时还能用于SharePoint Foundation. 方法一:日期筛选器Web部件 ...
- Sharepoint 2013列表视图和字段权限扩展插件(免费下载)!
记得2014年春节期间,有博客园的网友通过QQ向我咨询Sharepoint 2013列表视图和字段权限扩展,因为之前他看到我博客介绍Sharepoint 2010列表视图和字段的权限控制扩展使用,问有 ...
- Android列表视图(List View)
Android列表视图(ListView) ListView是一个显示滚动项列表的示视图组(viewgroup),通过使用适配器(Adapter)把这些列表项自动插入到列表中.适配器比如从一个数组或是 ...
- Android——列表视图(ListView)
列表视图是android中最常用的一种视图组件,它以垂直列表的形式列出需要显示的列表项.在android中有两种方法向屏幕中添加列表视图:一种是直接使用ListView组件创建:另外一种是让Activ ...
随机推荐
- C++ CSTRINGLIST用法
CStringList类成员 构造 CStringList 构造一个空的CString对象列表 首/尾访问 GetHead 返回此列表(不能是空的)中头部的元素 GetTail 返回此列表(不能是 ...
- 如何配置eclipse的安卓SDK下载目录
首先,打开eclipse,主界面如图 2 点击Windows下的preference 3 然后在出现的对话框中选择“android” 4 然后我们就能看到的主界面,在这里输入android sdk的目 ...
- Android sdk 目录结构说明
1.add-on:附加的包:2.docs:HTML格式的离线文档:3.platforms:sdk核心内容:4.tool:工具. 在platforms中包含了的各个Android SDK版本的目录中,包 ...
- 关于scp在zsh报错:zsh:no matches found :
我要将某一目录下面所有文件拷贝的时候,scp *.jpg 的时候,报错 zsh: no matchs found:path 其实是zsh自己解析了*号,所以,只要给*加上就可以了\ scp \*.jp ...
- Linux 安装 iptables防火墙
CentOS7默认的防火墙不是iptables,而是firewalle. 安装iptable iptable-service #先检查是否安装了iptables service iptables st ...
- 前端三大框架之一React入门教程
相信大家对框架这个词都很熟悉吧,我一直喜欢js原生来开发,但是目前都要求工作效率,所有使用框架或者是库会使我们开发更加方便和快速,甚至一个人干十个人的活.. 框架优点: 1.方便开发.快速写功能 2. ...
- Java方法的重载和重写
重载与重写对比: 重载: 权限修饰符(public private 默认):无关 方法名:重载的两个方法的方法名必须相同 形参的个数不同 形参的类型不同 三者至少满足一个 返回值类型: 重载与返回值 ...
- npm run build
[npm run build] npm 会在项目的 package.json 文件中寻找 scripts 区域,其中包括npm test和npm start等命令. 其实npm test和npm st ...
- cdnbest如何查看站点操作日志(同步日志)
1. 在区域列表点同步日志 2. 点击进入后,可以查看对哪个站点进行了操作,操作时间,ip,id都有记录 3. 想知道详细操作了什么内容把鼠标指向操作类型,就会弹出操作的信息
- 外购半成品报SHORT问题(非验货客户)
外购半成品报SHORT问题(验货客户)https://www.cnblogs.com/Snowfun/p/8660646.html 下面看非验货客户: 1.检查采购类型是否为F(SAP_MARC),为 ...