我意识到,对于Context.getTheme(),如果我们使用Application作为Context,它通常不会很好
MyApplication.singletonInstance().getTheme().resolveAttribute(R.attr.actionBarDeleteIcon, typedValue, true);
// typedValue.resourceId will be 0x0, which is invalid
但是,如果我使用Activity作为上下文,它运行良好
MyFragment.this.getActivity().getTheme().resolveAttribute(R.attr.actionBarDeleteIcon, typedValue, true);
// typedValue.resourceId is valid
我想知道为什么我们不能通过应用程序解析属性?
在清单中,我们在应用程序级别找到特定的主题信息.所以,我认为从Application对象获取主题确实有意义.
android:theme="..."