Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference

MESSAGE

错误提示: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference

解决方法: Replace this line : getResources().getDrawable(R.drawable.your_drawable)

with
ResourcesCompat.getDrawable(getResources(), R.drawable.your_drawable, null)

参考:http://stackoverflow.com/questions/29041027/android-getresources-getdrawable-deprecated-api-22

你可能感兴趣的:(Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference)