首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> 更多程式語言 >> 程式設計綜合問答

Android Manifest 設定主題報錯:資源找不到的修正

     編輯:程式設計綜合問答

錯誤程式碼

<activity android:name=".Funfriends"
    android:theme="@string/Texttheme"
    android:label="@string/app_name">

錯誤原因

@string/Texttheme 參考的是字串資源,但主題屬性需要 樣式資源(@style/...)。

修正方法

將 @string/Texttheme 改為 @style/Texttheme:

<activity android:name=".Funfriends"
    android:theme="@style/Texttheme"
    android:label="@string/app_name">

完整資源定義

<!-- res/values/styles.xml -->
<resources>
    <style name="Texttheme">
        <item name="android:textColor">#ff0000</item>
    </style>
</resources>

補充說明

  • @string/ 用於文字資源,@style/ 用於樣式/主題,@color/ 用於顏色。
  • 主題可繼承系統主題:parent="android:Theme.Holo.Light"。
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved