Why doesn't the icon and text appear in the ActionBar in the Android app?

I am starting Android development and I am trying to create my own theme, but I have a problem. I tried to find answers on google, d.android, but to no avail.

ActionBarchanges color (this is normal), but the text and application icon are not displayed (only if I use my theme - if I use the default theme, everything is fine). Why?

RES / values ​​/ styles.xml:

<resources xmlns:android="http://schemas.android.com/apk/res/android">

<style name="AppBaseTheme" parent="android:Theme.Light">
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

<style name="MyActionBar" parent="AppTheme">
    <item name="android:background">HEX COLOR</item>
    <item name="android:titleTextStyle">@style/MyTitleTextStyle</item>
</style>

<style name="MyTitleTextStyle" parent="AppTheme">
    <item name="android:textColor">#FFFFFF</item>
</style>

</resources>

Here is my AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.appname"
        android:versionCode="1"
        android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name="com.example.appname.Intro"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>
+4
source share
2 answers

, AppTheme MyActionBar, . MyActionBar → AppTheme → MyActionBar... android:Widget.ActionBar .

android:Theme.Holo.Light android:Theme.Light AppBaseTheme.

res/values ​​/styles.xml:

<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="AppBaseTheme" parent="android:Theme.Holo.Light"/>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
    </style>

    <style name="MyActionBar" parent="android:Widget.ActionBar">
        <item name="android:background">HEX COLOR</item>
        <item name="android:titleTextStyle">@style/MyTitleTextStyle</item>
    </style>

    <style name="MyTitleTextStyle" parent="AppTheme">
        <item name="android:textColor">#FFFFFF</item>
    </style>

</resources>
0

Msgstr " onCreate().

getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setIcon(R.drawable.ic_launcher); "

+1

All Articles