图文列表,关于Simpleadapter
main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
</RelativeLayout>
su.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="60dp" android:orientation="horizontal">
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="5dp"
android:layout_marginLeft="8dp" />
<LinearLayout
android:layout_toRightOf="@+id/img"
android:layout_width="match_parent"
android:layout_height="60dp" android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginTop="5dp"
android:layout_marginLeft="20dp" android:textSize="16sp"
/>
<TextView
android:id="@+id/info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp" android:textSize="10sp"/> </LinearLayout> </LinearLayout>
MainActivity.java:
public class MainActivity extends Activity {
private ListView lv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv = (ListView)findViewById(R.id.listview);
SimpleAdapter adapter = new SimpleAdapter(this,getData(),
R.layout.su,
new String[] {"img","title","info"},
new int[] {R.id.img,R.id.title,R.id.info});
lv.setAdapter(adapter);
} private List<Map<String,Object>> getData(){
List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
Map<String,Object> map = new HashMap<String,Object>();
map.put("img",R.drawable.s1802);
map.put("title","Smith");
map.put("info", "电台DJ");
list.add(map); map = new HashMap<String,Object>();
map.put("img",R.drawable.s1804);
map.put("title","西施");
map.put("info", "四大美女之一");
list.add(map); map = new HashMap<String,Object>();
map.put("img",R.drawable.s1805);
map.put("title","大圣归来");
map.put("info", "国产电影");
list.add(map); map = new HashMap<String,Object>();
map.put("img",R.drawable.s1809);
map.put("title","旗木卡卡西");
map.put("info", "copy忍者");
list.add(map); map = new HashMap<String,Object>();
map.put("img",R.drawable.s1810);
map.put("title","飞雷神之术");
map.put("info", "来无影去无踪");
list.add(map); map = new HashMap<String,Object>();
map.put("img",R.drawable.s1811);
map.put("title","HelloKitty");
map.put("info", "女生的最爱");
list.add(map); map = new HashMap<String,Object>();
map.put("img",R.drawable.s1816);
map.put("title","机械暴龙兽");
map.put("info", "亚古兽的完全体");
list.add(map); map = new HashMap<String,Object>();
map.put("img",R.drawable.s1811);
map.put("title","HelloKitty");
map.put("info", "女生的最爱");
list.add(map); return list;
}
}
图文列表,关于Simpleadapter的更多相关文章
- NEC学习 ---- 模块 - 上图下文图文列表
上图下文图文列表的效果如下图: 可以看到三个红色框中的三中"上图下文的图文列表"; 这里的代码其实没什么问题, 对于这种布局, 其实可以参考我上一篇介绍: NEC学习 ---- 模 ...
- [转]ionic3项目实战教程三(创建provider、http请求、图文列表、滑动列表)
本文转自:https://blog.csdn.net/lyt_angularjs/article/details/81145468 版权声明:本文为博主原创文章,转载请注明出处.谢谢! https:/ ...
- python 全栈开发,Day126(创业故事,软件部需求,内容采集,显示内容图文列表,MongoDB数据导入导出JSON)
作业讲解 下载代码: HBuilder APP和flask后端登录 链接:https://pan.baidu.com/s/1eBwd1sVXTNLdHwKRM2-ytg 密码:4pcw 如何打开APP ...
- 软件部需求,内容采集,显示内容图文列表,MongoDB数据导入导出JSON
全局变量 由于多个html页面,需要引用同一个变量.这个时候,需要定义一个全局变量!如何定义呢? 默认包含了mui的html文件都导入mui.js文件.那么将变量写在mui.js中,就可以实现所有页面 ...
- Vue(小案例_vue+axios仿手机app)_图文列表实现
一.前言 1.导航滑动实现 2.渲染列表信息时让一开始加载的时候就请求数据 3.根据路由的改变,加载图文的改变(实现用户访问网站时可能执行的三个操作) 二.主要内容 1.导航滑动实现: (1)演示 ...
- NEC学习 ---- 模块 - 左图右文图文列表
该模块效果图: 这个模块也是在开发中经常使用的一种: HTML代码: <div class="container"> <div class="m-lis ...
- Jquery滚动到页面底部自动Ajax加载图文列表,类似图片懒加载效果,带加载效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Discuz 首页图文列表实现
<div id="shoucang"> <!--{eval $list_count=0;}--> <!--{loop $threadlist $thr ...
- jQuery+ajax实现滚动到页面底部自动加载图文列表效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
随机推荐
- js 事件委托代理
在优化网页性能的技巧当中,对DOM的优化是必不可少的.这其中就涉及到了javascript对DOM的频繁操作.比如响应用户操作的事件.一般情况下,如果是稍微初级一点的前端程序员,在拿到项目的时候,对待 ...
- 自定义适用于手机和平板电脑的 Dynamics 365(四):窗体脚本
为 Web 应用程序中使用的窗体编写的脚本也应该适用于用于手机和平板电脑的 Dynamics 365,但存在一些差异. 通常,对于移动应用程序无效的方法不返回错误,但是它们也不返回任何值. 开发人员可 ...
- CentOS7上Python3.5安装
CentOS7上Python3.5安装 1.下载 https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz 2.上传到服务器 3. yum in ...
- Python学习笔记之—— File(文件) 对象常用函数
file 对象使用 open 函数来创建,下表列出了 file 对象常用的函数: 1.file.close() close() 方法用于关闭一个已打开的文件.关闭后的文件不能再进行读写操作, 否则会触 ...
- 接口自动化 基于python实现的http+json协议接口自动化测试框架源码(实用改进版)
基于python实现的http+json协议接口自动化测试框架(实用改进版) by:授客 QQ:1033553122 欢迎加入软件性能测试交流QQ群:7156436 目录 1. ...
- Android--用JS去控制WebView显示的字体的大小
<script type="text/javascript"> function changeFontSize(size) { var tfs = '120%'; va ...
- python turtle 绘制图像
def _circle(): t = turtle.Turtle() t.pencolor("yellow") t.pensize(5) t.speed(200) t.circle ...
- CSS样式----CSS属性:字体属性和文本属性(图文详解)
本文最初于2015-10-04发表于博客园,并在GitHub上持续更新前端的系列文章.欢迎在GitHub上关注我,一起入门和进阶前端. 以下是正文. 本文重要内容 CSS的单位 字体属性 文本属性 定 ...
- Mongodb集群与分片 1
分片集群 Mongodb中数据分片叫做chunk,它是一个Collection中的一个连续的数据记录,但是它有一个大小限制,不可以超过200M,如果超出产生新的分片. 下面是一个简单的分片集群 ...
- YYYY-mm-dd HH:MM:SS大小写解释
d 月中的某一天.一位数的日期没有前导零. dd 月中的某一天.一位数的日期有一个前导零. ddd 周中某天的缩写名 ...