I am new to android and currently trying to follow Android developer training and learn the use of action bar. For some reason can't see any icon on my action bar.
Here are steps I did (saw also previous stackoverflow threads about it):
Step 1: Just followed the training instrucations. According to it, all you need is to set the min sdk to the menifest element and also set a Theme and here is what I did. In adition I installed Android Support Repository (ver 11) to support the theme.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.guy.guaranteemanager" >
<uses-sdk android:minSdkVersion="11" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat">
...
</application>
</manifest>
Result: in my emulator I see the title but don't see an icon.
Step 2: I tried to implicitely set the icon in the activity xml element
<activity
android:name=".MainActivity"
android:icon="@drawable/ic_launcher"
android:label="Main Page 1">
Result: See the updated title but no icon.
Step 3: I tried to change it from the code:
ActionBar actionBar = getSupportActionBar();
actionBar.setIcon(R.drawable.ic_launcher);
setTitle("My new title");
Result: See the updated title but no icon.
Step 4: This question is not a duplication of the linked question, because based on this linked suggested answer, I tried to replace
actionBar.setIcon(R.drawable.ic_launcher);
with:
actionBar.setLogo(R.drawable.ic_launcher);
Result: See the updated title but no icon.
So - What is blocking my icon from being presented. Is it some XML definition? the theme is not right? something else?
My related styles.xml looks like that:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>