![](/img/trans.png)
[英]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.