8

サポート アクション バーを使用するには、アクティビティで ActionBarActivity を拡張する必要があります。それを実行してアクティビティを開始すると、アプリケーションが次のようにクラッシュします。

例外: このアクティビティでは Theme.AppCompat テーマ (または子孫) を使用する必要があります。

私のstyles.xmlには

<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light"></style>

そして、私が持っている問題のあるアクティビティの AndroidManifest.xml で

<activity android:name="com.example.test3.SettingsActivity"
          android:theme="@style/AppBaseTheme" />
4

3 に答える 3

2

この行をマニフェスト ファイルに書き込みます。

 android:theme="@style/Theme.AppCompat.Light.NoActionBar"

サンプル:

   <activity
        android:name="com.vmoksha.BaseActivity"
        android:label="@string/app_name" 
        android:theme="@style/Theme.AppCompat.Light.NoActionBar"
        >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

そして、リソースタグ内のstyles.xmlにこのコードを追加します

      <style name="Theme.AppCompat.Light.NoActionBar" parent="@style/Theme.AppCompat.Light"> 
        <item name="android:windowNoTitle">true</item>
     </style>

乾杯!

于 2014-05-27T11:12:48.963 に答える
1

Tsung W 氏は次のように述べています。

<style name="Theme.Event" parent="Theme.AppCompat">

次に、AndroidManifest.xml でテーマを設定します。

<application
   android:debuggable="true"
   android:name=".activity.MyApplication"
   android:allowBackup="true"
   android:icon="@drawable/ic_launcher"
   android:label="@string/app_name"
   android:theme="@style/Theme.Event.Home">
于 2014-03-13T17:16:54.477 に答える