I wound up doing this in code --
((ImageButton) findViewById
(R.id.MyButton)).setOnFocusChangeListener(new OnFocusChangeListener()
{
public void onFocusChange(View view, boolean hasFocus) {
view.setBackgroundResource(hasFocus ?
R.drawable.focus_bg : 0);
}
});
Which seems like the easiest way...
On Sep 18, 2:36 am, Mark Murphy <[email protected]> wrote:
> sdphil wrote:
> > I want to change the android:background value when an image button is
> > selected (selected, not clicked). What's the easiest way to do that?
>
> Step #1: Find the existing StateListDrawable resource for ImageButton
> from the Android source code -- it should be an XML file
>
> Step #2: Copy that resource to your project
>
> Step #3: Replace various states (e.g., selected="true") in that XML with
> alternative nine-patch PNG files, perhaps by modifying one of the
> existing ones
>
> --
> Mark Murphy (a Commons
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to *Advanced* Android Development_
> Version 1.1 Available!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---