TextView在if else中改变字体颜色无法获取到xml里面所设置的颜色值

if(mPatients.get(position).getUploadFlag().equals("1")){
            mViewHolder.selectItem.setBackgroundResource(R.drawable.btn_null);
            mViewHolder.selectItem.setTextColor(UiUitls.getContent()
                    .getResources().getColor(R.color.gray));
        } else {
            mViewHolder.selectItem.setBackgroundResource(R.drawable.btn_blue);
            Resources resource = UiUitls.getContent().getResources();
            ColorStateList csl = resource.getColorStateList(R.color.blue_text);
            if (csl != null) {
                mViewHolder.selectItem.setTextColor(csl);
            }
//            mViewHolder.selectItem.setTextColor(UiUitls.getContent()
//                    .getResources().getColor(R.color.blue_text));
        }
如果使用注释中的代码,就只能获取到默认的颜色 无法获取到获取焦点的颜色。


blue_text.xml
<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:state_pressed="true" android:color="#fff"/> <!-- pressed -->

    <item android:state_focused="true" android:color="#00a0e9"/> <!-- focused -->

    <item android:color="#00a0e9"/> <!-- default -->

</selector>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值