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
  • 相关阅读:
    django缓存,信号,orm性能,多数据库配置
    git实战
    Web框架
    Windows Server 2012 R2 管理员密码忘记如何修改密码
    主机记录和记录值
    Python的类
    GenomicRangeQuery Find the minimal nucleotide from a range of sequence DNA.
    Countdiv-Codility Lesson5
    Windows域控时间不正确,设置互联网NTP服务器时间自动同步
    Missing Smallest positive integer
  • 原文地址:https://www.cnblogs.com/leestar54/p/3383605.html
Copyright © 2011-2022 走看看