赞
踩
来自极客开源团队(GKe OpenSource Code Team )贡献
本人新晋菜鸟一名,写些博客记录自己的成长经历,同时也希望给想入门的新手提供一些借鉴。
本文主要介绍如何给listview中的item设置点击后改变背景颜色,顺便简单介绍如何在fragment中显示listView。(本实例item加载的是静态数据!)本文包含较为详细的代码,非常适合新手学习使用。
1.新建fragment的xml格式布局文件,该布局文件比较简单,只有一个listview控件:
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:id="@+id/headLineList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#000000"
android:listSelector="@null"
android:divider="#EDEDEF"
android:dividerHeight="0.5dp">
2.新建一个listview item的xml格式布局文件:
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/hlTitle"
android:paddingLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。