NullPointerException at android.content.ContextWrapper

前端 未结 2 1238
失恋的感觉
失恋的感觉 2021-01-19 03:29

When I try to get a color via getResources().getColor(R.color.yellow) in a normal Activity I get this exception:

07-12 11:58:38.019: E/AndroidRu         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-19 04:02

    int backgroundColor = Color.YELLOW;
    

    instead of

    int backgroundColor = getResources().getColor(R.color.yellow);
    

提交回复
热议问题