You need to use a Theme.AppCompat theme (or descendant) with this activity.
錯誤描述為:java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
起因:我想在Manifest中設定我的activity全屏,程式碼如下:
<activity
android:name=".MainActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:label="@string/app_name" >
原因:從錯誤提示中提到Theme.AppCompat theme,這是因為我們的activity一定是繼承了相容包中的類,比如我這裡就無意中繼承了ActionBarActivity,它來自android.support.v7.app.ActionBarActivity。所以就要使用與其配合的AppCompat的theme才行。
解決:1.根據提示來使用AppCompat的theme,如下:
<activity
android:name=".MainActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:label="@string/app_name" >
不過我要設定全屏,但我並沒有找到,所以雖然錯誤不見了,但並沒有達到我的預期。
2.如果不是那麼強烈需要繼承自ActionBarActivity,就直接繼承Activity吧。問題自然搞定!
相關文章
- [譯] You Might Not Need ES6
- 理解BERT Transformer:Attention is not all you need!ORM
- 目標檢測:Segmentation is All You Need ?Segmentation
- You need tcl 8.5 or newer in order to run the Redis testRedis
- Access denied; you need (at least one of) the PROCESS privilege(s)AST
- [翻譯]What You Need to Begin iOS ProgrammingiOS
- Server-side activities have been updated. You need to restart SharePoint Designer to use the updated version of activities.ServerIDEREST
- For v$ views you need to grant privilege to each v_$ directlyView
- Android Theme.AppCompat 中,你應該熟悉的顏色屬性AndroidAPP
- You want to use parallel processes for a client copy.Parallelclient
- 經典譯文:Transformer--Attention Is All You NeedORM
- you cannot use this control in design mode。
- Everything you need to know about mobile app architectureAPP
- 一文讀懂「Attention is All You Need」| 附程式碼實現
- fuse: mountpoint is not empty fuse: if you are sure this is safe, use the ‘nonempty‘ mount optionNone
- crontab工具報錯crontab:you are not authorized to use cron.Sorry.Zed
- QUESTION :What kind of shared storage do you use for Oracle RAC?Oracle
- 黑猴子的家:Redis 之 You need tcl 8.5 or newer in order to run the Redis testRedis
- "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?APP
- [Paper Reading] KOSMOS: Language Is Not All You Need: Aligning Perception with Language Models
- use database 切換提示You can turn off this feature to get a quicker startupDatabaseUI
- XPath學習:軸(3)——descendant
- Mac 下的MySQL ERROR 1227(42000): Access denied; you need (at least one of)MacMySqlErrorAST
- 馬斯克開源的 grok-1 底層 Transformer 模型論文 《Attention is All You Need》馬斯克ORM模型
- 安裝rlwrap-0.37.tar.gz報錯You need the GNU readline library to buildUI
- Attention isn’t all you need!Mamba混合大模型開源:三倍Transformer吞吐量大模型ORM
- 更新jenkins外掛,報錯 Perhaps you need to run your container with "-Djava.awt.headless=true"?JenkinsAIJava
- sqlplus login -- SP2-0750: You may need to set ORACLE_HOME to your Oracle software directorySQLOracle
- Unknown host ‘XXXX: nodename nor servname provided, or not known‘. You may need to adjust the proxyIDE
- linux下安裝安裝pcre-8.32 configure: error: You need a C++ compiler for C++ supportLinuxErrorC++Compile
- Do we need HACMP?ACM
- 好用到爆的Kotlin擴充套件庫AndroidKTX,如果你也用Kotlin開發Android,You Need It !Kotlin套件Android
- PHP 7.3 "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? 解決方法PHPUI
- android-Implementing Descendant Navigation,Notifying the UserAndroidNavigation
- You've got to find what you loveGo
- [Javascript] Why need arrow function?JavaScriptFunction
- AntBlazor Theme in ABP FrameworkBlazorFramework
- 【轉載】Kano Model — Ways to use it and NOT use it