12

アプリのテーマを完全に変更しようとしています。これは私が変更して試したものです:

styles.xml値フォルダーには

<resources>

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

</resources>

値-v11styles.xml

<resources>

<!--
    Base application theme for API 11+. This theme completely replaces
    AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo">
    <!-- API 11 theme customizations can go here. -->
</style>

</resources>

値-v14styles.xml

<resources>

<!--
    Base application theme for API 14+. This theme completely replaces
    AppBaseTheme from BOTH res/values/styles.xml and
    res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo">
    <!-- API 14 theme customizations can go here. -->
</style>

</resources>

Mainifest.xml

<application
   .....
   android:theme="@style/AppTheme" >
   .......
</application>

ActionBarActivity&を使用していますappcompat_v7が、アプリがクラッシュしますjava.lang.RuntimeException: Unable to start activity ComponentInfo{com...}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity

何か足りないのでしょうか...?

どうすればこの問題を解決できますか?

助けてください...

前もって感謝します !


編集: Appcompat テーマを使用する場合、テーマはライトで、コードは次のとおりです。

したがって、 appcompat テーマstyles.xmlを値フォルダーで使用すると、

<resources>

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

</resources>

値-v11styles.xml

<resources>

<!--
    Base application theme for API 11+. This theme completely replaces
    AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <!-- API 11 theme customizations can go here. -->
</style>

</resources>

値-v14styles.xml

<resources>

<!--
    Base application theme for API 14+. This theme completely replaces
    AppBaseTheme from BOTH res/values/styles.xml and
    res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- API 14 theme customizations can go here. -->
</style>

</resources>

Mainifest.xml

<application
   .....
   android:theme="@style/AppTheme" >
   .......
</application>

appcompat テーマをライトからホロダークに変更する方法がわかりません。助けてください

4

1 に答える 1

35

tyczj が指摘しTheme.AppCompatたように、アプリで を使用する場合は、テーマの親として使用する必要がありますappcompat_v7。視覚的には(暗い)Theme.AppCompatと同じです。Theme.Holo

詳細については、Android ドキュメントの ActionBar のスタイリングに関する記事を参照してください。

于 2014-08-06T14:26:13.363 に答える