Hi Hackbod,

Thanks for that. Sometimes I make this stuff seem harder than it is! I
think XML is the way to go, coming from a J2EE background I like the
MVC style a bit better. But either way works, thanks again to both of
you.

Kevin

On Aug 20, 6:44 pm, hackbod <[EMAIL PROTECTED]> wrote:
> This can actually all be done in XML.  Just make a drawable that is a
> selector of the desired images.  For example, here is the standard
> button background drawable:
>
> <?xml version="1.0" encoding="utf-8"?>
> <!-- Copyright (C) 2008 Google Inc.
>
>      Licensed under the Apache License, Version 2.0 (the "License");
>      you may not use this file except in compliance with the License.
>      You may obtain a copy of the License at
>
>          http://www.apache.org/licenses/LICENSE-2.0
>
>      Unless required by applicable law or agreed to in writing,
> software
>      distributed under the License is distributed on an "AS IS" BASIS,
>      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
>      See the License for the specific language governing permissions
> and
>      limitations under the License.
> -->
>
> <selector xmlns:android="http://schemas.android.com/apk/res/android";>
>     <item android:state_window_focused="false"
> android:state_enabled="true"
>         android:drawable="@drawable/btn_default_normal" />
>     <item android:state_window_focused="false"
> android:state_enabled="false"
>         android:drawable="@drawable/btn_default_normal_disable" />
>     <item android:state_pressed="true"
>         android:drawable="@drawable/btn_default_pressed" />
>     <item android:state_focused="true" android:state_enabled="true"
>         android:drawable="@drawable/btn_default_selected" />
>     <item android:state_enabled="true"
>         android:drawable="@drawable/btn_default_normal" />
>     <item android:state_focused="true"
>         android:drawable="@drawable/
> btn_default_normal_disable_focused" />
>     <item
>          android:drawable="@drawable/btn_default_normal_disable" />
> </selector>
>
> On Aug 20, 9:07 am, "Chris Chiappone" <[EMAIL PROTECTED]> wrote:
>
> > Not sure if this is the best way but it seems to work fine for what
> > you want to do.
>
> > I basically set the Button background image in the layout XML first.
> > Then set up custom listeners (touch, click, onFocus) that call the
> > following method that replaces the background image with another
> > background image
>
> > public void setBackgroundCellResource(View view, String position,
> > boolean selected){
>
> >         if(position.equals(POSITION_TOP)){
> >                 if(selected){
> >                         
> > view.setBackgroundResource(R.drawable.btn_52_top_dn);
> >                 }else{
> >                         
> > view.setBackgroundResource(R.drawable.btn_52_top_up);
> >                 }
> >         }else if(position.equals(POSITION_BOT)){
> >                 if(selected){
> >                         
> > view.setBackgroundResource(R.drawable.btn_52_bot_dn);
> >                 }else{
> >                         
> > view.setBackgroundResource(R.drawable.btn_52_bot_up);
> >                 }
>
> >         }else if(position.equals(POSITION_MID)){
> >                 if(selected){
> >                         
> > //view.setBackgroundResource(R.drawable.btn_52_middle_dn);
> >                 }else{
> >                         
> > view.setBackgroundResource(R.drawable.btn_52_middle_up);
> >                 }
> >         }else{
> >                 if(selected){
> >                         
> > view.setBackgroundResource(R.drawable.btn_single_dn);
> >                 }else{
> >                         
> > view.setBackgroundResource(R.drawable.btn_single_up);
> >                 }
> >         }
>
> >     }
>
> > Hope that helps,
>
> > ~chris
>
> > On Wed, Aug 20, 2008 at 5:21 AM, cyntacks <[EMAIL PROTECTED]> wrote:
>
> > > I know a similar question has been asked before, specifically
> > > regarding the m5 sdk, but here it goes for the .9 release.
>
> > > I noticed that the new gui (which is awesome by the way) shows the
> > > icons on the home screen with no background, but they act like
> > > ImageButons in that when you click them the background "lights up"
> > > yellow. Is there a way to replicate this behavior in our applications?
> > > Currently all of my image buttons have the default "button
> > > border" (i.e. a big white margin around the image).
>
> > > I've searched through the new sdk's codebase but can't seem to figure
> > > out how this was done.
>
> > > As always, any help would be appreciated.
>
> > > Kevin
>
> > --
> > ~chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new Android 0.9 SDK beta!
http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to