码迷,mamicode.com
首页 > 其他好文 > 详细

Textview组件点击变色和替换左边背景小图

时间:2015-01-22 17:07:04      阅读:89      评论:0      收藏:0      [点我收藏+]

标签:

public void onClick(View v) {
         // TODO Auto-generated method stub
            switch (v.getId()) {
            case R.id.list_find_zan:
                
                TextView list_find_zany=(TextView) v;
                
                Resources resource = (Resources) getBaseContext().getResources();
                ColorStateList csl = (ColorStateList) resource
                        .getColorStateList(R.color.color_text_selected);
                list_find_zany.setTextColor(csl);
                Drawable drawable= getResources().getDrawable(R.drawable.load_hover);
                /// 这一步必须要做,否则不会显示.
                drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
                list_find_zany.setCompoundDrawables(drawable, null, null, null);
                break;

            default:
                break;
            }
        
         }

 

Textview组件点击变色和替换左边背景小图

标签:

原文地址:http://www.cnblogs.com/xiaoli3007/p/4241738.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!