i use Sherlock Actionbar
1, i wanna change Home Button BG when i press from blue to Red
2, i wanna change HomeAsUp icon (white arrow) any idea ?
Home button
pressed
here is created this actionbar code
extends SherlockFragmentActivity
public ActionBar actionBar;
this.actionBar = this.getSupportActionBar();
this.actionBar.setDisplayShowHomeEnabled(true);
this.actionBar.setHomeButtonEnabled(true);
this.actionBar.setDisplayHomeAsUpEnabled(true);
To change a button's color every time it's clicked:Add a click event listener to the button. Each time the button is clicked, set its style. backgroundColor property to a new value. Use an index variable to track the current and next colors.
..... <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="bonjour !" android:textColor="@color/button_text_color" /> ..... Not @drawable/button_text_color , but @color/button_text_color .
Use a semi-colon to separate the different style elements in the HTML button tag. Type color: in the quotation marks after "style=". This element is used to change the text color in the button. You can place style elements in any order in the quotation markers after "style=".
You can change this by specifying your own actionBarItemBackground
attribute in your theme.
For example,
<style name="Theme.MyTheme" parent="Theme.Sherlock">
<item name="android:actionBarItemBackground">@drawable/my_cool_drawable</item>
<item name="actionBarItemBackground">@drawable/my_cool_drawable</item>
</style>
and then specify Theme.MyTheme
in the manifest for your activity.
usually when you want to create this behavior in Android, you need to create a new selector
file (xml in /drawable
folder).
in that file what you want to do is choose the different states for the button and choose the different images for them.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/pressed_image" android:state_pressed="true"></item>
<item android:drawable="@drawable/regular_image"></item>
</selector>
edit:
you need to do this in the actionbarSherlock library of course.
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