简体   繁体   English

您需要在设计库中使用主题

[英]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.

相关问题 java.lang.IllegalArgumentException:您需要将Theme.AppCompat主题(或后代)与设计库一起使用 - java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library 您需要使用Theme.AppCompat主题 - You need to use a Theme.AppCompat theme “您需要使用Theme.AppCompat主题” - “You need to use a Theme.AppCompat theme” 错误消息:您需要与此活动一起使用Theme.AppCompat主题 - Error Message: You need to use a Theme.AppCompat theme with this activity 显示对话框 - IllegalStateException:您需要使用 Theme.AppCompat 主题 - Display dialog - IllegalStateException: You need to use a Theme.AppCompat theme 错误:您需要在此活动中使用Theme.AppCompat主题(或后代) - Error: You need to use a Theme.AppCompat theme (or descendant) with this activity 您需要使用 Theme.AppCompat 主题 --> 在单元测试中 - You need to use a Theme.AppCompat theme --> in Unit Test 问题与您需要与此活动一起使用Theme.AppCompat主题(或后代)与该活动一起Theme.AppCompat主题(或后代)” - Issue with You need to use a Theme.AppCompat theme (or descendant) with this activity Theme.AppCompat theme (or descendant) with this activity" 您需要使用Theme.AppCompat主题错误,即使主题设置为AppCompat也是如此 - You need to use a Theme.AppCompat theme error, even with theme set to AppCompat 在 android 中具有自定义主题的应用程序,错误:您需要在此活动中使用 Theme.AppCompat 主题(或后代) - app with custom theme in android, error: You need to use a Theme.AppCompat theme (or descendant) with this activity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM