Why getDrawable() doesn't work on some Android devices?

后端 未结 3 2036
耶瑟儿~
耶瑟儿~ 2021-02-07 01:16

I am getting \"nosuchmethod error\" on some user\'s phones (eg. Motorola Razr i) but it works fine on my HTC. Below is the code.

Drawable rBlack;
rBlack = getRes         


        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-07 01:50

    Try adding the following line of code:

    context.getResources().getDrawable(R.drawable.your_image_name);
    

提交回复
热议问题