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. android loadlibrary 更改libPath 路径,指定路径加载.so

    http://www.jianshu.com/p/f751be55d1fb 字数549 阅读177 评论0 喜欢0 需求很简单 ,就是加载指定文件夹下的.so. 原因:android在程序运行的状态下 ...

  2. php里ezpdo orm框架初探

    http://jackyrong.iteye.com/blog/238930 http://www.oschina.net/project/tag/126/orm?sort=view&lang ...

  3. ###学习《C++ Primer》- 1

    点击查看Evernote原文. #@author: gr #@date: 2014-09-30 #@email: forgerui@gmail.com 记录读书过程中一些知识点.可能不系统,:-). ...

  4. c# 中模拟一个模式匹配及匹配值抽取

    摘一段模式的说明, F#的: msdn是这么描述它的:“模式”是用于转换输入数据的规则.模式将在整个 F# 语言中使用,采用多种方式将数据与一个或多个逻辑结构进行比较.将数据分解为各个构成部分,或从数 ...

  5. 理解css 中的position五个属性

    在实际开发页面布局时,运用position,对定位的块级元素的嵌套的效果总是不太理解,这里做了几个测试 一般的在w3c中我们可以很容易的获取定义: static : 默认值.没有定位,元素出现在正常的 ...

  6. checkbox prop()函数

    1.设置checkbox选中状态 ①选中: .prop('checked',true); ②不选中:.prop('checked',false); 2.获取checkbox选中状态 .prop('ch ...

  7. HDU 4763 (KMP算法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4763 题目大意:给定一串字符,从中找出符合“EAEBE”格式的E的最大字符数.AB可以是任意数量的任意 ...

  8. c++实现类似Common Lisp的多参数加法和比较

    在CL里我们可以这样: $ sbcl * (+ 1 2 3) 6 * (< 1 2 3) T * (< 2 3 1) NIL * 从简单的方面看, CL的+和<就是一个接收多参数的函 ...

  9. ueditor使用代码高亮的方法

    最近发现ueditor支持代码高亮,但是页面上并没有起效果,于是网上找了下,发现还需做如下修改: 1.页面引用以下资源文件(均位于ueditor目录中): <script type=" ...

  10. 【HeadFirst设计模式】8.模板方法模式

    模板方法 定义: 在一个方法中定义一个算法的骨架,而将一些步骤延迟到子类中.模板方法使用得子类可以在不改变算法结构的情况下,重新定义算法中的某些步骤. 策略模式: 定义一个算法家族,并让这些算法可以互 ...