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 ...
随机推荐
- Nginx深度优化
简介 1.隐藏版本号2.修改Nginx用户与组3.配置Nginx网页缓存时间4.实现Nginx的日志切割5.配置Nginx实现连接超时6.更改进程数7.配置Nginx实现网页压缩功能8.配置Nginx ...
- python 2.X 和 3.X 的区别汇总
python 2.x python 3.x print() 或者 print “abc”都可以 ...
- MPI Maelstrom-单源最短路-Djsktra
BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distribute ...
- cacti报ERROR: unknown option '--border' 解决方法
cacti制图报下面提示 if (isset($rrdborder) && $rrdversion >= 1.4) { $graph_opts .= "--border ...
- smtp扫描
nc扫描 nc -nv ip号 25 nmap扫描
- Numpy:索引与切片
numpy基本的索引和切片 import numpy as np arr = np.array([1,2,3,555,666,888,10]) arr array([ 1, 2, 3, 555, 66 ...
- jenkins权限控制
一.插件安装 插件:Role-based Authorization Strategy版本:2.3.2 二.全局安全配置 进入Jenkins后点击系统管理进入全局安全配置 当插件安装好的时候,授权策略 ...
- css3修改滚动条样式
/*滚动条整体样式*/ /*高宽分别对应横竖滚动条的尺寸*/ .content-box::-webkit-scrollbar{ width: 4px; height: 4px; } /*滚动条里面小方 ...
- Spyder启动黑屏,终端显示QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked QOpenG
cd /etc/ld.so.conf.d目录中有 i386-linux-gnu_GL.conf and x86_64-linux-gnu_GL.conf等文件cat x86_64-linux-gnu_ ...
- CentOS 查看是否安装软件包
1. rpm包安装的,可以用rpm -qa看到,如果要查找某软件包是否安装,用 rpm -qa | grep "软件或者包的名字" 2. deb包安装的,可以用dpkg -l能看到 ...