Android ListView(Selector 颜色)
listview_color.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="match_parent"
android:orientation="vertical" > <ListView
android:id="@+id/listViewColor"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:choiceMode="singleChoice"
android:divider="@android:color/darker_gray"
android:dividerHeight="1dp" >
</ListView> </LinearLayout>
aa.java
package com.wangzhu.demoselector; import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView; public class ListViewColorActivity extends Activity { private ListView listViewColor; private ArrayAdapter<String> colorAdapter; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listview_color);
initView();
} private void initView() {
listViewColor = (ListView) findViewById(R.id.listViewColor);
colorAdapter = new ArrayAdapter<String>(this, R.layout.list_item_color,
R.id.item_tv, getResources().getStringArray(
R.array.listviewDatas));
listViewColor.setAdapter(colorAdapter);
}
}
list_item_color.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="match_parent"
android:background="@drawable/list_item_bg_color_selector"
android:orientation="vertical" > <TextView
android:id="@+id/item_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content" /> </LinearLayout>
list_item_bg_color_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/green" android:state_pressed="true"/>
<item android:drawable="@color/red" android:state_activated="true"/>
<item android:drawable="@color/white"/> </selector>
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources> <string-array name="listviewDatas">
<item>星期一</item>
<item>星期二</item>
<item>星期三</item>
<item>星期四</item>
<item>星期五</item>
<item>星期六</item>
<item>星期日</item>
</string-array> </resources>
color.xml
<?xml version="1.0" encoding="utf-8"?>
<resources> <color name="black">#000000</color>
<color name="red">#ff0000</color>
<color name="green">#00ff00</color>
<color name="white">#ffffff</color> </resources>
Android ListView(Selector 颜色)的更多相关文章
- android 常用selector 颜色搭配(按钮、显示圆角等)
作为开发者,我们时常会遇到UI常用色调搭配不协调的情况,UI也只有一个白板原型图,这时我们有一套自己常用的好看的selector会很快调出自己想要的风格. 下面是我常用的一些色调,仅供大家参考: 蓝色 ...
- android ListView 九大重要属性详细分析、
android ListView 九大重要属性详细分析. 1.android ListView 一些重要属性详解,兄弟朋友可以参考一下. 首先是stackFromBottom属性,这只该属性之后你做好 ...
- Android ListView OnItemLongClick和OnItemClick事件内部细节分享以及几个比较特别的属性
本文转自 http://blog.sina.com.cn/s/blog_783ede030101bnm4.html 作者kiven 辞职3,4个月在家休息,本以为楼主要程序员逆袭,结果失败告终继续码农 ...
- 【转】android ListView 几个重要属性
android ListView 几个重要属性 分类: Android2012-03-08 19:25 19324人阅读 评论(5) 收藏 举报 listviewandroid活动javalistnu ...
- Android的selector,背景选择器
原文地址 http://android.blog.51cto.com/268543/564581 首先android的selector是在drawable/xxx.xml中配置的,相关图片放在同目录下 ...
- 浅谈android的selector,背景选择器
shape和selector的结合使用 (2013-04-07 11:11:00) 转载▼ 分类: android 1.Shape (1)作用:XML中定义的几何形状 (2)位置:res/draw ...
- Android的selector 背景选择器
关于listview和button都要改变android原来控件的背景,在网上查找了一些资料不是很全,所以现在总结一下android的selector的用法.首先android的selector是在d ...
- Android ListView的item背景色设置以及item点击无响应等相关问题
Android ListView的item背景色设置以及item点击无响应等相关问题 在Android开发中,listview控件是非常常用的控件,在大多数情况下,大家都会改掉listview的ite ...
- Android ListView 几个重要属性
Android ListView 几个重要属性http://blog.csdn.net/avenleft/article/details/7334060 android:transcriptMode= ...
- Android ListView圆角
首先来看看ListView 相关基本属性 1.单击列表后,列表的背景变成黑色了. 可通过指定android:cacheColorHint的属性来放变它,将它指定为透明. 使用以下的属性值: a ...
随机推荐
- 有关line-height的见解
line-height:简单的说就是行高,是两行文字之间基线的距离.基线是指在英语的书写的4线3格中,从上往下数的第三条线 1.line-height与行内框盒子模型 所有内联元素的样式表现都与行内框 ...
- android事件分发介绍
Android事件分发 事件分发3个步骤 dispatchTouchEvent(event)派发 onInterceptTouchEvent(event)拦截 onTouchEvent(eve ...
- hibernate设置mysql的timestamp默认值技巧
首先,要想使用数据库中配置的默认值就必须不让hibernate覆盖了默认值,需要配置property insert="false" update="false" ...
- 【JAVA】浅谈java枚举类
一.什么情况下使用枚举类? 有的时候一个类的对象是有限且固定的,这种情况下我们使用枚举类就比较方便? 二.为什么不用静态常量来替代枚举类呢? public static final int SEASO ...
- POJ 1170 Shopping Offers -- 动态规划(虐心的六重循环啊!!!)
题目地址:http://poj.org/problem?id=1170 Description In a shop each kind of product has a price. For exam ...
- Apache Shiro入门实例
Shiro是一个强大灵活的开源安全框架,提供身份验证.授权.会话管理.密码体系. 1.先创建一个Maven项目 2.配置pom <project xmlns="http://maven ...
- Json操作
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- 树莓派实现TimeMachine以及samba服务
最近一段时间感觉用移动硬盘备份Mac电脑很不方便,因为要把移动硬盘拿出来,还要插上电脑备份,看了一下AirPort,但是价钱太贵,况且只能用于Mac备份并不能用于其他的Samba服务等,感觉不太划算, ...
- 探究为何rem在chrome浏览器上计算出错
最近在一个项目中,测试同学提了一个bug,说手机上有个页面的某些字体显示偏大.就像这样 我用chrome浏览器在pc上测试了一下,发现pc上也有这个问题,但是用其它浏览器打开这个页面就没有发现这个问题 ...
- Sql语句批量更新数据(多表关联)
最近在项目中遇到一个问题,原来设计的功能是不需要一个特定的字段值depid的,但是新的功能需要根据depid来展现,于是出现了这样一个问题,新增加的数据都有正确的depid,而原来的大量的数据就没有d ...