图文列表,关于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/ ...
随机推荐
- 前端了解即可:postman(接口测试)的使用
postman的使用,前端了解即可.因为都是一些工具的应用,截图比较多,之前在有道云笔记上总结记录过,在这不在写了,展示一张笔记截图. 此文仅做参考一下,有不足之处,欢迎指正:
- phpstudy集成下Apache配置部署https安全证书
一..先申请到安全证书.(腾讯云或者阿里云申请免费1年的安全证书),怎么申请这里也说下(以腾讯云为例): 1.登录腾讯云QQ或微信登录都行,第一次登录要通过实名认证,点击[产品]---[ss证书l] ...
- RaPC(rasterized polygon clipper): A discrete grid-based polygon clipping algorithm
RaPC(rasterized polygon clipper)-A discrete grid-based polygon clipping algorithm This algorithm is ...
- 在JavaScript文件中用jQuery方法实现日期时间选择功能
JavaScript Document $(document).ready(function(e) { 在文本框里面显示当前日期 var date = new Date(); var nian = d ...
- python 多进程、多线程
1.多线程: 下面讲一个简单用法,这个模块比较简单,但是实际使用中会遇到很多坑 from multiprocessing import process def go(s): print "主 ...
- JBoss EAP应用服务器部署方法和JBoss 开发JMS消息服务小例子
一.download JBoss-EAP-6.2.0GA: http://jbossas.jboss.org/downloads JBoss Enterprise Application Platfo ...
- python之绘制图形库turtle
关于绘制图形库turtle# 画布上,默认有一个坐标原点为画布中心的坐标轴(0,0),默认"standard"模式坐标原点上有一只面朝x轴正方向小乌龟 一:海龟箭头Turtle相关 ...
- Fabric密码保存
参考:https://segmentfault.com/a/1190000000497630 多个IP分别使用不同的账号.密码 from fabric.api import * env.hosts = ...
- Android之间传递数据包
在Android中 ,我们知道,两个activity之间通讯要用到Intent类,传递简单数据的方式我们也已经知道了.那么,如何在两个activity之间传递数据包呢,这就要用到我们的Bundle类了 ...
- Nginx 配置支持 WebSocket
找到nginx的配置文件:nginx.conf,增加以下三行配置. 示例: server { listen 80; server_name www.test.com; location / { pro ...