1

I am new at Android, I am getting in Android action bar menu text is capital form but I want the text Change#0333 like I described in the following example image. Please how can I achieve this? Thanks.

enter image description here

This is my Code:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);

    menu.getItem(0).setTitle("change#0" + defaultmsisdn.substring(2));

    return true;
}

And this is my main.xml file in res/menu folder:

<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="com.ufoneselfcare.MainActivity" >

<item
    android:id="@+id/change_number_menu"
    android:orderInCategory="100"
    android:title="@string/action_settings"
    app:showAsAction="always|withText"/>

</menu>
Lennon Spirlandelli
  • 3,131
  • 5
  • 26
  • 51
newOnAndroid
  • 141
  • 3
  • 16
  • possible duplicate of [How to style the menu items on an Android action bar](http://stackoverflow.com/questions/6072226/how-to-style-the-menu-items-on-an-android-action-bar) – Lamorak May 25 '15 at 16:06

2 Answers2

2

In your app's theme (in styles.xml), you will have an app theme, which you can customise. A blank one might look a bit like this:

<style name="MyTheme" parent="Theme.AppCompat.Light">

</style>

What you need to do in order to have lowercase menu items is to use the attribute actionMenuTextAppearance, so using the above example, you will end up with something like this:

<style name="MyTheme" parent="Theme.AppCompat.Light">
    <item name="android:actionMenuTextAppearance">@style/MyMenuTextAppearance</item>
</style>

<style name="MyMenuTextAppearance" parent="TextAppearance.AppCompat.Widget.ActionBar.Menu">
    <item name="android:textAllCaps">false</item>
</style>
Farbod Salamat-Zadeh
  • 19,687
  • 20
  • 75
  • 125
1

Try this and hope it's worked:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);

menu.getItem(0).setTitle(Html.fromHtml( "<u>change#0" + defaultmsisdn.substring(2)+"</u>"));

return true;
}
Farhan Shah
  • 2,344
  • 7
  • 28
  • 54