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
  • 相关阅读:
    Linux网卡上添加多个IP
    TCP_Wrappers基础知识介绍
    工作、生活、思考、人生、经验、总结
    网络层安全
    centos7.0 安装nginx
    linux 下配置jdk
    yii2.0 中的队列
    centos7.0 activemq的安装
    solrCloud
    线性顺序表
  • 原文地址:https://www.cnblogs.com/leestar54/p/3383605.html
Copyright © 2011-2022 走看看