What went wrong on my code that Its not able to show my any Android ActionBar icons. Below is my code: Correct where its getting missed.
My style.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
My themes.xml: I have used custom theme. I think from here I need to change to show icons
<?xml version="1.0" encoding="utf-8"?>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="android:actionMenuTextColor">@style/MyActionBarTitleText</item>
<item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/PrimaryColor</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText"
parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:background">@color/ActionBarTitleText</item>
</style>
<!-- ActionBar tabs text styles -->
<style name="MyActionBarTabText"
parent="@android:style/Widget.Holo.ActionBar.TabText">
<item name="android:textColor">@color/ActionBarTitleText</item>
</style>
MainActivity:
//ActionBar creating/adding icon in Menu
@Override
public boolean onCreateOptionsMenu(Menu menu){
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.main_activity_menu, menu);
return super.onCreateOptionsMenu(menu);
}
//ActionBar Menu icon listerner like clicking options
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()){
case R.id.info:
Toast.makeText(getApplicationContext(),
"Info Selected",Toast.LENGTH_SHORT).show();
case R.id.st:
Toast.makeText(getApplicationContext(),
"Setting Selected",Toast.LENGTH_SHORT).show();
default:
return super.onOptionsItemSelected(item);
}
}
main_activity_menu.xml: I have tried "always" & "IfRoom" But its not working.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
<item
android:id = "@+id/info"
android:title="info"
android:icon="@drawable/ic_info_outline_white_24dp"
app:showAsAction="always|withText">
</item>
<item
android:id = "@+id/st"
android:title="settings"
android:icon="@drawable/ic_settings_white_24dp"
app:showAsAction="always">
</item>