There was a post about that in this group, but I can't find it now!! Very wired!!!!
You can search for "how to make a view touchable visiually". If u find it, you will see how to set different backgrounds in different states(pressed, long pressed, focused, etc). Furthermore, if these drawables you set are pics you are actually set the "shape"! On Oct 16, 6:39 pm, Shoby <[email protected]> wrote: > Hi Farproc, > > Could you please provide a sample code or a link to a sample code for > the same????? > > Thanks, > Shoby > > On Oct 16, 3:04 pm, Farproc <[email protected]> wrote: > > > > > Set button's background to a StateListDrawable object or xml resource. > > > Here is a sample to use StateListDrawable resource. It's very easy you > > event do not need to write the listeners!!! > > > On 10月16日, 下午5时43分, Shoby <[email protected]> wrote: > > > > Hi i am developing an application that has a button whose color should > > > change green color on focusing on the button and the color of button > > > should change to red on clicking the button. I am using > > > setBackgroundResource() in the onClick and onLongClick listeners. > > > Though it changes the button color, it also changes the button shape > > > by making it look like a rectangle. How can this be solved? i have > > > used the below code to do the same: > > > > final Button b = (Button)findViewById(R.id.Button01); > > > b.setOnLongClickListener(new View.OnLongClickListener(){ > > > > public boolean onLongClick(View v) { > > > b.setBackgroundResource(R.color.green); > > > return false; > > > } > > > }); > > > > b.setOnClickListener(new View.OnClickListener() { > > > public void onClick(View view) { > > > b.setBackgroundResource(R.color.red); > > > } > > > > }); > > > > How can i achieve the functionality with out changing the shape of the > > > button???? > > > Can someone tell me how this functionality can be achieved? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

