继承父状态,然后使用Selector
如果是用Linearlayout里面动态添加Linearlayout的情况,就要代码控制了
// 就是为了改变颜色。
                    ly.setOnTouchListener(new OnTouchListener() {
 
                        @Override
                        public boolean onTouch(View v, MotionEvent event) {
                            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                                foodName.setTextColor(getResources().getColor(R.color.color_text_p));
                            }
                            if (event.getAction() == MotionEvent.ACTION_UP) {
                                foodName.setTextColor(getResources().getColor(R.color.color_text));
                            }
                            // 乱移就要用这个
                            if (event.getAction() == MotionEvent.ACTION_CANCEL) {
                                foodName.setTextColor(getResources().getColor(R.color.color_text));
                            }
                            return false;
                        }
                    });
别忘了给相应的ly加上setOnClickListener

ListItem选中时只改变文字的颜色的更多相关文章

  1. 【转载】input只改变光标的颜色 不改变字的颜色

    转载 http://www.cnblogs.com/yangAL/p/6934608.html color: red; text-shadow: 0px 0px 0px #000; -webkit-t ...

  2. input只改变光标的颜色 不改变字的颜色

    color: red; text-shadow: 0px 0px 0px #000; -webkit-text-fill-color: transparent;把这些放到input里文字通过阴影实现 ...

  3. Echarts无数据时只显示文字不显示动画

    只需要在option中加入如下代码即可: noDataLoadingOption: {                        text: '暂无数据',                     ...

  4. 设置TabBarItem选中时的图片及文字颜色

    TabBarItem选中时,默认文字和图片都变为蓝色.使用以下代码可以进行修改. MainViewController *mainVC = [[MainViewController alloc] in ...

  5. 转 Android RadioButton设置选中时文字和背景颜色同时改变

    主要应用在购物车,像淘宝的那样,点击以后弹出一个选择种类颜色这样的popuwindow以后,然后这个选择种类的地方要用到类似这个玩意儿. 搜了一下,效果和这个文章一致.转了. 原文地址:http:// ...

  6. Android RadioButton设置选中时文字和背景颜色同时改变

    主要应用在购物车,像淘宝的那样,点击以后弹出一个选择种类颜色这样的popuwindow以后,然后这个选择种类的地方要用到类似这个玩意儿. 搜了一下,效果和这个文章一致.转了. 原文地址:http:// ...

  7. 改变listview中item选中时文字的颜色

    摘要 当listview的某个item选中时,默认有个选中的高亮显示,如果你要自定义选中时的高亮显示效果,可以在listview中设置属性 android:listSelector="@dr ...

  8. 设置 TabBarItem 选中时的图片及文字颜色

    TabBarController 是在 ios 开发过程中使用较为频繁的一个 Controller,但是在使用过程中经常会遇到一些问题,例如本文所要解决的,如何修改 TabBar 选中时文字及图片的颜 ...

  9. IOS - UITableViewCell的选中时的颜色及tableViewCell的selecte与deselecte

    1.系统默认的颜色设置 [cpp] view plaincopy //无色 cell.selectionStyle = UITableViewCellSelectionStyleNone; //蓝色 ...

随机推荐

  1. ios 判断空字符串

    - (BOOL) isBlankString:(NSString *)string { if (string == nil || string == NULL) { return YES; } if ...

  2. Codeforces Round #250 (Div. 2)

    感觉不会再爱了,呜呜! A题原来HACK这么多!很多人跟我一样掉坑了! If there is some choice whose description at least twice shorter ...

  3. 用dedecms自定义表单创建简易自助预约系统

    建站往往需要根据客户的需求来增加相应的功能,比如预约.平时用比较多的是织梦系统,那么如何用dedecms自定义表单创建简易自助预约系统呢? 进入dedecms后台,左侧菜单中依次点击“核心” - 频道 ...

  4. tomcat与IIS在多IP服务器下的支持

    同一个服务器下,双IP(或更多IP),实现tomcat与IIS公用80端口. 操作其实也很简单的,首先禁用iis的套接字池,iis绑定一个ip,然后tomcat在绑定另一个ip,最后重启下服务器即可. ...

  5. Tomcat server分端口部署web项目

    <?xml version='1.0' encoding='utf-8'?> <Server port="8006" shutdown="SHUTDOW ...

  6. iOS第三方支付-支付宝支付

    处理手机中有无支付宝的情况支付宝调用接口: - (void)payOrder:(NSString *)orderStr      fromScheme:(NSString *)schemeStr    ...

  7. POJ 2101

    #include <iostream> #include <algorithm> #include <cmath> using namespace std; int ...

  8. C# WINFORM 捕获全局异常

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Thr ...

  9. JS加载时间线

    1.创建Document对象,开始解析web页面.解析HTML元素和他们的文本内容后添加Element对象和Text节点到文档中.这个阶段document.readyState = 'loading' ...

  10. java重构、重载、重写

    重构:就是代码优化,或则你可以理解为代码的修改!            例:开始你的类名是A现在要改为B也称为重构的一种 重载:发生在同一类中,方法名相同,参数列表不同 重写:发生在父子类中,子类中有 ...