图文列表,关于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/ ...
随机推荐
- 排序算法(1)--Insert Sorting--插入排序[1]--straight insertion sort--直接插入排序
作者QQ:1095737364 QQ群:123300273 欢迎加入! 1.基本思想 将一个记录插入到已排序好的有序表中,从而得到一个新,记录数增1的有序表.即:先将序列的第1个记录看成 ...
- nginx禁止ip默认参数是$remote_addr无法禁止真实ip的问题
由于网站使用了cdn所以$remote_addr获取的ip是cdn的ip,我现在先禁止某些ip访问发现无法禁止cdn传递过来的客户端的ip也就是$http_x_forwarded_for这个参数.比如 ...
- Lambda表达式 For Android
Lambda简介 A lambda expression is a block of code with parameters. lambda表达式是带参数的代码块. 虽然看着很先进,其实Lambda ...
- EL表达式和标签
1.什么是EL expression language 表达式语言 特点: 语言简单,使用方便 .${表达式}. 提供自动类型转换的功能 如果返回结果为null时 String -- ”” Numbe ...
- winform调用jar包
因为工作需要,需要做一个数据上传的程序,客户规定的是:数据接口采用http连接,采用JSON-RPC轻量级远程调用协议.所以决定用winform做一个管理界面(其中还包括其他的功能),java完成数据 ...
- 下载 VM 模板
使用门户或 PowerShell 在 Azure 中创建 VM 时,系统会自动创建一个 Resource Manager 模板. 可以使用此模板快速复制部署. 该模板包含有关资源组中所有资源的信息. ...
- IHttpModule 和 IHttpHandler 配置方法
<?xml version="1.0" encoding="utf-8"?> <configuration> <appSettin ...
- 调用百度翻译API接口功能
public string appid = "自己的APPID"; public string q = "要翻译的文本"; "; public str ...
- [Python_3] Python 函数 & IO
0. 说明 Python 函数 & IO 笔记,基于 Python 3.6.2 参考 Python: read(), readline()和readlines()使用方法及性能比较 Pyt ...
- [Spark SQL_1] Spark SQL 配置
0. 说明 Spark SQL 的配置基于 Spark 集群搭建 && Hive 的安装&配置 1. 简介 Spark SQL 是构建在 Spark Core 模块之上的四大 ...