直接说过程吧:
1.构建一个HashMap:
ArrayList<HashMap<String, String>> dlist = new ArrayList<HashMap<String, String>>();
for (int i = 0; i < data.length; i++) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("data", data[i]);
dlist.add(map);
}
2.设置SimpleAdapter:
SimpleAdapter adapter = new SimpleAdapter(this, dlist,
R.layout.list_item, new String[] { "data" },
new int[] { R.id.entries });
list.setAdapter(adapter);
3.主要在list_item上:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/selector">
<TextView android:text="data" android:id="@+id/entries"
android:layout_width="match_parent" android:layout_height="wrap_content">
</TextView>
</LinearLayout>
4.上述item上设置了背景:selector.xml:
<item android:state_selected="true">
<shape>
<gradient android:angle="270" android:endColor="#ffffffff"
android:startColor="#ffffffff" />
<padding android:left="15dp" android:top="20dp"
android:right="15dp" android:bottom="20dp" />
<size android:height="60dp" android:width="320dp" />
<corners android:radius="8dp" />
</shape>
</item>
"android:state_selected="true""这个属性还有:"android:state_pressed="true""或者不设置表示默认的时候背景情况.
我写在这里是为了后续编码的时候参考的......:)
分享到:
相关推荐
主要介绍了WPF的ListView控件自定义布局的方法,结合实例形式分析了WPF中ListView控件的布局方法,需要的朋友可以参考下
C#的ListView添加各种自定义控件,CheckBox,ComboBox等
android中listview中的item内容不一样时,我们就可以通过自定义adapter来判断和控制不同的item显示内容
实现ListView自定义Item,重写代理类,实现类似网易云pc客户端地效果
适合学习listView 和自定义适配器朋友使用。 有点击item 触发传值. 标题一》》》》》内容一 标题二》》》》》内容二 可以实现这种点击这种效果
NULL 博文链接:https://aichixihongshi.iteye.com/blog/1129584
为便于学习自定义的Adapter,本案例的界面未进行美化,功能已经实现,对于其中的getView(int position,View view ,...本案例功能及其简单,只涉及ListView中自定义适配器,没有对其中的点击等其他操作进行展开。
Android ListView边框圆角美化,可以用来仿iphone的个别界面。相当有用。美观。
listview 自定义adapter的例子demo
Flutter学习之旅(六)----ListView控件自定义Adapter以及带参数跳转,博客对应地址:http://blog.csdn.net/zhangxiangliang2/article/details/76383244
简单的listview自定义适配器的使用方法,注释很清晰,也有对应的博文介绍
C# 强大的自定义ListView ObjectListViewFull-2.4.1
Android自定义adapter的listview代码
用WIN32编写的自定义LISTVIEW控件
【ListView】自定义控件:下拉刷新,亲测,可正常运行,有注释。
自定义listview的header样式,代码是eclipse版的
自定义ListView的Item圆角样式,打破传统平凡样式ListView。
android listview 自定义样式实例 可以改造成自己所需风格
ListView自定义Adapter实现多视图Item