ActionBar過時問題

XML報錯,什麼都沒動的時候就這樣:android

Rendering Problems The following classes could not be found: 
android.support.v7.internal.app.WindowDecorActionBar 
(Fix Build Path, Create Class)    
Tip: Try to build the project.

在stackoverflow上找到解決辦法: #####原文連接:找不到ActionBar

  • 方法1:
The Actionbar has been deprecated and replaced by Toolbar. That being said, you can do the following if you want to continue using Actionbar for now:    
   1.Open styles.xml in the values folder inside the res folder.
   2.Add the word Base to the beginning of the theme name so that it reads "Base.Theme.AppCompat.Light.DarkActionBar"
    I had the same issue today and this solution worked for me. FYI I am in Android Studio though, but hopefully the solution is similar for Eclipse.
   FYI here is a decent blog post on replacing the Actionbar with the Toolbar for when you are ready to do so: ...

翻一下意思就是ActionBar過時了,已經被ToolBar給取代了,在高版本中想用ActionBar須要:
1.打開styles.xml
2.BaseTheme也就是AppTheme改爲"Base.Theme.AppCompat.Light.DarkActionBar"
#####關於ToolBar歡迎閱讀:ToolBar的進階閱讀(英文的)

  • 方法2:
I think you must be depending on "com.android.support:appcompat-v7:23.1.1" in your module settings.
    ActionBar has been deprecated.
Just change your dependencies from 'com.android.support:appcompat-v7:23.1.1' to 'com.android.support:appcompat-v7:23.0.1' in "build.gradle".
    You can also change your style parent to "Theme.AppCompat.Light.NoActionBar".
    Try to use the Toolbar instead of ActionBar.

大體翻譯:如今的v7包依賴的ActionBar過時了,在"build.gradle"將依賴的版本改低點'com.android.support:appcompat-v7:23.1.1'-->'com.android.support:appcompat-v7:23.0.1'.
或者說將style改爲"Theme.AppCompat.Light.NoActionBar"
推薦各位嘗試去使用ToolBar替代ActionBarapp

相關文章
相關標籤/搜索