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
  • 相关阅读:
    mysqldump详解
    mysql忽略表中的某个字段不查询
    mysqldumpslow基本使用
    xtrabakcup基本用法 安装、全量备份恢复、增量备份恢复
    Ubuntu--磁盘统计
    Ubuntu--硬盘的挂载与卸载
    Ubuntu--文件属性权限管理(command: chmod, chown)
    Ubuntu--useradd指令使用
    Ubuntu--安装sshd开启远程登陆服务
    Ubuntu--虚拟机中Ubuntu系统时间与windows不同步
  • 原文地址:https://www.cnblogs.com/leestar54/p/3383605.html
Copyright © 2011-2022 走看看