I'm building and finishing a Android App and this is one of the main things I need to Fix it up.
So, I have a Action Bar styled like this:
<resources>
<style name="MyCustomTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyActionBarTheme</item>
</style>
<style name="MyActionBarTheme" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#F6E6E7</item>
<item name="android:textSize">10sp</item>
</style>
<style name="CustomTabWidget">
<item name="android:textSize">15sp</item>
</style>
</resources>
And this is the layout where i put the button
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Search, should appear as action button -->
<item android:id="@+id/voltar"
android:title="Voltar"
android:icon="@drawable/abc_ic_ab_back_holo_light"
android:showAsAction="ifRoom" />
<!-- Settings, should always be in the overflow -->
</menu>
this Button Tittled Voltar is at the Right Side of the Action Bar.. What Should I Do to put this on Left Side?
Thank you for read this
You need to do two things. First declare this in the onCreate
of your activity
getActionBar().setDisplayHomeAsUpEnabled(true);
Then implement the onOptionsItemSelected
so that it handles the home as up button click event
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home ) {
finish();
return true;
}
// other menu select events may be present here
return super.onOptionsItemSelected(item);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With