To change the button backgroung after navigation

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

To change the button backgroung after navigation

Postby Jeevanantham143 » Thu Feb 04, 2010 12:58 pm

I have a button in white colour(default) in my first activity and i have changed the colour to red onClick.

onClick i am going to 2nd activity and when i come back from 2nd to 1st activity the button is still in red colour. but i want it to be in white colour.

Can somebody help me to aceive that?...
Jeeva
Jeevanantham143
Freshman
Freshman
 
Posts: 7
Joined: Thu Feb 04, 2010 12:51 pm

Top

Postby Jeevanantham143 » Tue Feb 09, 2010 11:09 am

Create abc.xml in drawable folder having the following content.

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/[image name to be displayed on click]"/>
<item android:drawable="@drawable/[Default image name]"/>
</selector>


Then give:
<Button
android:background="@drawable/abc"
/>

Now your button will change colour when clicked and will turn to default colour after onClick event...
Jeeva
Jeevanantham143
Freshman
Freshman
 
Posts: 7
Joined: Thu Feb 04, 2010 12:51 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 7 guests