2015-11-02 73 views
2

我已經開始深入研究應用程序開發,並且我正在關注一些在線教程,並且遇到了此呈現問題。每當我選擇除AppTheme.NoActionBar以外的任何主題時,我都會收到以下錯誤信息。Ubuntu 14.04 -Android Studio:以下類無法實例化

以下類不能被實例化: - android.support.design.widget.CoordinatorLayout(公開課,顯示異常,清除緩存) - android.support.design.widget.AppBarLayout(公開課,顯示異常,清除緩存)提示:使用View.isInEditMode()在您的自定義 意見跳躍代碼或IDE 異常顯示詳細信息

java.lang.IllegalArgumentException異常時,表明樣本數據:你需要使用一個主題.AppCompat 主題(或後代)與設計庫。在 android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:34) 在 android.support.design.widget.CoordinatorLayout。(CoordinatorLayout.java:178) 在 android.support.design.widget .CoordinatorLayout。(CoordinatorLayout.java:172) 在java.lang.reflect.Constructor.newInstance(Constructor.java:422) 在 android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 在android.view .LayoutInflater.inflate(LayoutInflater.java:492)at android.view.LayoutInflater.inflate(LayoutInflater.java:394)將 堆棧複製到剪貼板

通過更改樣式中的appTheme和更改AndroidManifest中的東西,查看建議的所有解決方案here,但似乎沒有任何工作。我仍然在我的主內容中收到渲染問題。

我Styles.xml:

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 

<style name="AppTheme.NoActionBar"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
</style> 

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> 

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

我的AndroidManifest.xml

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity 
     android:name=".MainActivity" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme.NoActionBar"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 

這是我的默認個XML,但即使是修改建議已經無濟於事。它已經2個月左右,我還沒有得到這個...

+0

可能的重複項:http://stackoverflow.com/questions/21331836/java-lang-illegalstateexception-you-need-to-use-a-theme-appcompat-theme-or-des,http:// stackoverflow。 com/questions/21814825/you-need-to-use-a-theme-appcompat-theme-or-descendant-with-this-activity or http://stackoverflow.com/questions/18063395/actionbarcompat-java-lang- illegalstateexception-you-need-to-use-a-theme-appcom – 2015-11-02 06:03:48

+1

我看過所有這些答案,我找不到我需要做的事情。 – Alkarin

+0

你可以嘗試重新創建緩存和索引。轉到文件 - >無效緩存/重啓....也許這有幫助! – Ock

回答

1

使用類似Theme.AppCompat.Light.NoActionBar。您可以在您的資源res/values/styles.xml中找到的styles.xml中進行設置。

+0

仍然遇到問題。 – Alkarin

相關問題