zoukankan      html  css  js  c++  java
  • ListItem选中时只改变文字的颜色

     继承父状态,然后使用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
  • 相关阅读:
    IDEA中快速排除maven依赖
    Maven构建war项目添加版本号
    运行shell脚本报/bin/bash^M: bad interpreter错误排查方法
    Shell杀tomcat进程
    根据URL下载文件
    关闭Centos的自动更新
    CentOS下建立本地YUM源并自动更新
    为Linux服务器伪装上Windows系统假象
    ServerInfo.INI解密
    请教给终端推销域名的邮件该怎么写?
  • 原文地址:https://www.cnblogs.com/leestar54/p/3383605.html
Copyright © 2011-2022 走看看