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的更多相关文章

  1. NEC学习 ---- 模块 - 上图下文图文列表

    上图下文图文列表的效果如下图: 可以看到三个红色框中的三中"上图下文的图文列表"; 这里的代码其实没什么问题, 对于这种布局, 其实可以参考我上一篇介绍: NEC学习 ---- 模 ...

  2. [转]ionic3项目实战教程三(创建provider、http请求、图文列表、滑动列表)

    本文转自:https://blog.csdn.net/lyt_angularjs/article/details/81145468 版权声明:本文为博主原创文章,转载请注明出处.谢谢! https:/ ...

  3. python 全栈开发,Day126(创业故事,软件部需求,内容采集,显示内容图文列表,MongoDB数据导入导出JSON)

    作业讲解 下载代码: HBuilder APP和flask后端登录 链接:https://pan.baidu.com/s/1eBwd1sVXTNLdHwKRM2-ytg 密码:4pcw 如何打开APP ...

  4. 软件部需求,内容采集,显示内容图文列表,MongoDB数据导入导出JSON

    全局变量 由于多个html页面,需要引用同一个变量.这个时候,需要定义一个全局变量!如何定义呢? 默认包含了mui的html文件都导入mui.js文件.那么将变量写在mui.js中,就可以实现所有页面 ...

  5. Vue(小案例_vue+axios仿手机app)_图文列表实现

    一.前言 1.导航滑动实现   2.渲染列表信息时让一开始加载的时候就请求数据 3.根据路由的改变,加载图文的改变(实现用户访问网站时可能执行的三个操作) 二.主要内容 1.导航滑动实现: (1)演示 ...

  6. NEC学习 ---- 模块 - 左图右文图文列表

    该模块效果图: 这个模块也是在开发中经常使用的一种: HTML代码: <div class="container"> <div class="m-lis ...

  7. Jquery滚动到页面底部自动Ajax加载图文列表,类似图片懒加载效果,带加载效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. Discuz 首页图文列表实现

    <div id="shoucang"> <!--{eval $list_count=0;}--> <!--{loop $threadlist $thr ...

  9. jQuery+ajax实现滚动到页面底部自动加载图文列表效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

随机推荐

  1. BZOJ3351: [ioi2009]Regions(根号分治)

    题意 题目链接 Sol 很神仙的题 我们考虑询问(a, b)(a是b的祖先),直接对b根号分治 如果b的出现次数\(< \sqrt{n}\),我们可以直接对每个b记录下与它有关的询问,这样每个询 ...

  2. 【代码笔记】iOS-对数组进行排序

    一,代码. - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, ...

  3. 解除mysql只有本机可以访问的限制

    1.终端:sudo vim /etc/mysql/my.cnf 2.找到bind-address,注释掉(前面加#) 这里出现问题,发现my.cnf打开根本没有bind-address,但是多了两句话 ...

  4. The D Programming Language 书评

    此书的作者 Andrei Alexandrescu 作为前 C++ 社区的一朵奇葩,因为实在是不满 C++ 标准委员会的官僚作风,跳槽到了 D 社区,成为了 D 发明人 Walt Brightman ...

  5. froala富文本编辑器与golang、beego,脱离ueditor苦海

    一直用百度的ueditor,可是阿里云这种"wo chuo"的云上部署的beego做的服务,总是出现ueditor.all.min.js语法错误,清理浏览器缓存后又会好起来.本地调 ...

  6. vs2017安装cuda9.0编译默认示例失败解决方法

    https://devtalk.nvidia.com/default/topic/1027209/cuda-setup-and-installation/cuda-9-0-does-not-work- ...

  7. Leetcode题解之Valid Palindrome II

    1.题目描述 2.问题分析 使用两个下标,检测下标对应的字符是否相等,若不相等,则考察子串. 3.代码 bool validPalindrome(string s) { , j = s.size()- ...

  8. 03-01_WebLogic一些概念名词

    WebLogic一些概念名词 域(Domain) 管理服务器(Administrative Server) 被管服务器(Managed Server,受管服务器) 集群(Cluster) 机器(Mac ...

  9. SQL Server自动备份 备份到本地或者远程服务器

    0.1 在SQLServer2008 --> 备份数据库 --> 安全 --> 新建用户 --> 用户名 选择该windows用户 (确保 --> 机器名/人名 --&g ...

  10. excel如何冻结首行或首列及首行首列同时冻结

    冻结首行方法: 首先选择首行,在菜单栏选择视图菜单,再选择冻结窗格下拉三角里的冻结首行即可. 效果如下:拖动垂直滚动条 冻结首列方法: 首先选择首列,在菜单栏选择视图菜单,再选择冻结窗格下拉三角里的冻 ...