[英]You need to use a theme with the design library
Sometimes after rebuilding my app I get fatal error 有时在重建我的应用程序后,我会遇到致命的错误
a IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library. a IllegalArgumentException:您需要将Theme.AppCompat主题(或后代)与设计库一起使用。
I have view-builder class and dynamically add views into the parent layout, it seems it works perfect if I use Activity context, but for some reasons I want to use Application context, so I have this method 我有视图构建器类并动态地将视图添加到父布局中,如果我使用Activity上下文它似乎是完美的,但由于某些原因我想使用Application上下文,所以我有这个方法
LayoutInflater provideLayoutInflater(Context context) {
context.setTheme(R.style.AppThemeDark);
return (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
context.setTheme(R.style.AppThemeDark);
it's hack and it seems it doesn't work as expected, but I'm not sure. 它是黑客,它似乎没有按预期工作,但我不确定。
Please help me to solve this issue. 请帮我解决这个问题。 Thanks for any help 谢谢你的帮助
如果主要活动是从AppCompatActivity扩展,则必须使用从AppCompat降序的主题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.