Compatibility of getContext and getResource between 5.0 and lower

前端 未结 1 1090
广开言路
广开言路 2020-12-20 05:34

Hi so I released my app a few months ago and it all was working fine and to a degree it still does. On devices running lower than android 5 everything is fine. But I tested

相关标签:
1条回答
  • 2020-12-20 06:31

    You need to use .equals to compare the objects.

    == check if it's the same object not if the objects hold the same value, more info here

    Your code shoud look like:

    if(Word1.getDrawable().getConstantState().equals(getResources().getDrawable( R.drawable.img9).getConstantState())
    
    0 讨论(0)
提交回复
热议问题