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

  1. android 常用selector 颜色搭配(按钮、显示圆角等)

    作为开发者,我们时常会遇到UI常用色调搭配不协调的情况,UI也只有一个白板原型图,这时我们有一套自己常用的好看的selector会很快调出自己想要的风格. 下面是我常用的一些色调,仅供大家参考: 蓝色 ...

  2. android ListView 九大重要属性详细分析、

    android ListView 九大重要属性详细分析. 1.android ListView 一些重要属性详解,兄弟朋友可以参考一下. 首先是stackFromBottom属性,这只该属性之后你做好 ...

  3. Android ListView OnItemLongClick和OnItemClick事件内部细节分享以及几个比较特别的属性

    本文转自 http://blog.sina.com.cn/s/blog_783ede030101bnm4.html 作者kiven 辞职3,4个月在家休息,本以为楼主要程序员逆袭,结果失败告终继续码农 ...

  4. 【转】android ListView 几个重要属性

    android ListView 几个重要属性 分类: Android2012-03-08 19:25 19324人阅读 评论(5) 收藏 举报 listviewandroid活动javalistnu ...

  5. Android的selector,背景选择器

    原文地址 http://android.blog.51cto.com/268543/564581 首先android的selector是在drawable/xxx.xml中配置的,相关图片放在同目录下 ...

  6. 浅谈android的selector,背景选择器

    shape和selector的结合使用 (2013-04-07 11:11:00) 转载▼   分类: android 1.Shape (1)作用:XML中定义的几何形状 (2)位置:res/draw ...

  7. Android的selector 背景选择器

    关于listview和button都要改变android原来控件的背景,在网上查找了一些资料不是很全,所以现在总结一下android的selector的用法.首先android的selector是在d ...

  8. Android ListView的item背景色设置以及item点击无响应等相关问题

    Android ListView的item背景色设置以及item点击无响应等相关问题 在Android开发中,listview控件是非常常用的控件,在大多数情况下,大家都会改掉listview的ite ...

  9. Android ListView 几个重要属性

    Android ListView 几个重要属性http://blog.csdn.net/avenleft/article/details/7334060 android:transcriptMode= ...

  10. Android ListView圆角

    首先来看看ListView 相关基本属性 1.单击列表后,列表的背景变成黑色了. 可通过指定android:cacheColorHint的属性来放变它,将它指定为透明. 使用以下的属性值:     a ...

随机推荐

  1. ASP生成静态文件编码为UTF-8格式的HTML文件

    一般在ASP环境下,运行动生静操作时都用到的是FSO,FSO是专门对文件进行操作的一个组件,FSO的编码属性只有三种,系统默认,Unicode,ASCII,并没有utf-8,所以一般中文系统上使用FS ...

  2. Python获取本机的mac,ip,name

    Python获取mac 获取计算机名字和ip(内网ip) 指定网卡ip

  3. js和jq使用submit方法无法提交表单

    昨天,在做一个表单异步提交内容的时候,遇到很奇怪的问题,submit()方法无法进行提交,每次提交都是把 当前给刷新了,网络抓包发现,每次都是 get方式去获取 当前页面,完全没有post 请求,想着 ...

  4. Java获取方法参数名、Spring SpEL解析

    @Test public void testParse() { //表达式解析 ExpressionParser expressionParser = new SpelExpressionParser ...

  5. fgetc, getchar(), fscanf的问题

    1.漫谈:为什么 函数fscanf(FILE stream, const char format, ...)的 第3个参数中 总是用变量的地址 或者是用指针. 这个问题涉及到 传值 和 传指针.一般情 ...

  6. Linux 驱动程序/内核模块/ko文件

    Linux 驱动程序/内核模块/ko文件 一.内核模块加载机制 1.解析 Linux 内核可装载模块的版本检查机制 二.驱动/内核模块 编译 1.The Linux Kernel Module Pro ...

  7. 暑假集训(2)第四弹 ----- 敌兵布阵(hdu1166)

    D - 敌兵布阵 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     64bit ...

  8. S.O.L.I.D

    S.O.L.I.D.是一组面对面向对象设计的最佳实践的设计原则.术语来自Robert C.Martin的著作Agile Principles, Patterns, and Practices in C ...

  9. hdu 4850 Wow! Such String! 欧拉回路

    作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4080264.html 题目链接:hdu 4850 Wow! Such String! 欧拉回 ...

  10. linux shell编程学习笔记(一)---通配符,元字符

    linux通配符: 通配符是由shell处理的(不是由所涉及到命令语句处理的,其实我们在shell各个命令中也没有发现有这些通配符介绍), 它只会出现在 命令的“参数”里(它不用在 命令名称里, 也不 ...