首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

经过代码设置color 类型的selector

2013-03-22 
通过代码设置color 类型的selector在代码中通过资源id设置selector类型的颜色往往不成功,需要用下面这种方

通过代码设置color 类型的selector

在代码中通过资源id设置selector类型的颜色值往往不成功,需要用下面这种方式来添加selector资源,然后这只给指定的View

try {
              XmlResourceParser xrp = getResources().getXml(R.color.father_btcolor);
               ColorStateList  cl = ColorStateList.createFromXml(getResources(), xrp);
               } catch (Exception ex) {}
    if(cl != null){

                                tl.setTextColor(cl);
          }

热点排行