如果直接继承ListAcitivty,则不需要自定义ListView,下面的是列表项单项显示格式
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3px"
/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
/>
<TextView
android:id="@+id/info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="10sp"
/>
</LinearLayout>
</LinearLayout>
Activity
package com.loulijun.demo13;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.SimpleAdapter;
public class Demo13Activity extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SimpleAdapter adapter = new SimpleAdapter(this, getData(),
R.layout.main, new String[] { "img", "title", "info" },
new int[] { R.id.img, R.id.title, R.id.info });
setListAdapter(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.e001);
map.put("title", "小宗");
map.put("info", "电台DJ");
list.add(map);
map = new HashMap<String, Object>();
map.put("img", R.drawable.e002);
map.put("title", "貂蝉");
map.put("info", "四大美女");
list.add(map);
map = new HashMap<String, Object>();
map.put("img", R.drawable.e04b);
map.put("title", "奶茶");
map.put("info", "清纯妹妹");
list.add(map);
map = new HashMap<String, Object>();
map.put("img", R.drawable.e04e);
map.put("title", "大黄");
map.put("info", "是小狗");
list.add(map);
map = new HashMap<String, Object>();
map.put("img", R.drawable.e11a);
map.put("title", "hello");
map.put("info", "every thing");
list.add(map);
map = new HashMap<String, Object>();
map.put("img", R.drawable.e11d);
map.put("title", "world");
map.put("coco
", "hello world");
list.add(map);
return list;
}
}
分享到:
相关推荐
Android SimpleAdapter的多种显示GridView/ListView
NULL 博文链接:https://aygxylxk.iteye.com/blog/1250203
Android SimpleAdapter 列表(ListView)、表格(GridView)
NULL 博文链接:https://thinkgoogle.iteye.com/blog/1313519
Android之simpleAdapter
使用SimpleAdapter和自定义Adapter分别实现了ListView的填充,自定义的还添加了一个删除的事件。
对于适配器加载自定义的xml布局文件,修改该Spinner样式较简单,就是在定义的xml布局文件中修改显示的样式就可以。但对于加载android自带的xml布局文件,有时会出现不是项目所需要的效果。主要问题有下拉几个: 1....
Android Studio —— SimpleAdapter (模仿魅蓝设置界面)。详情查看:https://blog.csdn.net/automoblie0/article/details/122631004
自定义Android适配器,简单的实现listview中可以响应button按钮
简单的ListView,适合新手学习
Android的AdapterView用的比较多,ListView,GridView,Spinner等,原生的BaseAdapter对ViewHolder没有支持,每次都要,定义内部类,inflater根布局,对item内部view设置clicklistener并转发到adapter的调用者等。...
自定义适配器 和 SimpleAdater 配合listView使用 ,将数据展示在列表中 进阶2
安卓Android源码——(列表之SimpleAdapter适配).zip
ListView使用simpleAdapter填充实现,数据结构是HashMap,对应的我的博客地址是: http://blog.csdn.net/u012320459/article/details/47667869
使用android studio开发显示网络图片,主要涉及HTTP协议,与数据流的知识点,对初学者研究如何从网络上获取图片,很有帮助
简单基础代码,关于listview的一个简单的图片加载列表。简单基础代码,关于listview的一个简单的图片加载列表
系统自带的list单选满足不了需求,本人特写实现了自定义listview实现单选来和大家分享!
安卓Android源码——(列表SimpleAdapter适配).rar
android 弹出菜单 采用自定义dialog(内部嵌套GridView) 跟开卷有益 一模一样 高度仿照 欢迎下载