[英]java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library
[英]You need to use a theme with the design library
有时在重建我的应用程序后,我会遇到致命的错误
a IllegalArgumentException:您需要将Theme.AppCompat主题(或后代)与设计库一起使用。
我有视图构建器类并动态地将视图添加到父布局中,如果我使用Activity上下文它似乎是完美的,但由于某些原因我想使用Application上下文,所以我有这个方法
LayoutInflater provideLayoutInflater(Context context) {
context.setTheme(R.style.AppThemeDark);
return (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
context.setTheme(R.style.AppThemeDark);
它是黑客,它似乎没有按预期工作,但我不确定。
请帮我解决这个问题。 谢谢你的帮助
如果主要活动是从AppCompatActivity扩展,则必须使用从AppCompat降序的主题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.