I realize, for Context.getTheme()
, it usually doesn't work well if we use Application
as the Context
MyApplication.singletonInstance().getTheme().resolveAttribute(R.attr.actionBarDeleteIcon, typedValue, true);
// typedValue.resourceId will be 0x0, which is invalid
However, if I use Activity
as context, it works well
MyFragment.this.getActivity().getTheme().resolveAttribute(R.attr.actionBarDeleteIcon, typedValue, true);
// typedValue.resourceId is valid
I was wondering why we cannot resolve attribute through Application
?
In manifest, we specific theme information is found at Application
level. So, I thought getting theme from Application
object does make sense.
<application
android:theme="..."