java.lang.NoSuchMethodError: android.content.res.Resources.getDrawable /getColor

    java.lang.NoSuchMethodError: android.content.res.Resources.getDrawable/getColor 异常错误。

              

 

   原因:Context类的getDrawable(res)/geColor(res)方法和Resources的getDrawable(res,theme)/getColor(res.theme)都是API21才添加的,低版本系统无法找到该方法所以报异常。

 

   解决办法:
     使用Resources的 getDrawable(res),但是该方法在API22已废弃。
     使用 ContextCompat.getDrawable(context,res)。
如:ContextCompat.getDrawable(MainActivity.this,R.drawable.radio_btn_background_show);

     

 

posted @ 2017-04-13 10:39  风如故  阅读(687)  评论(0编辑  收藏  举报