I want to change the background color and text color of a button when pressed(it should remain in the state until again button is pressed). Also if pressed again i need the old state of button. Anyone help me please
Here is the screenshots (Normal state)
Here is the code what i have tried
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/beco_white"
android:layout_marginTop="@dimen/dp10"
android:orientation="horizontal">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/button_oberon_mall"
android:layout_width="92dp"
android:layout_height="30dp"
android:layout_marginLeft="@dimen/dp10"
android:minWidth="92dp">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/blue_rounded_corner_new"
android:text="Oberon Mall"
android:fontFamily="sans-serif-regular"
android:textAllCaps="false"
android:textColor="@color/beco_black"
android:textSize="13sp"/>
</FrameLayout>
</FrameLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/button_centre_square_mall"
android:layout_width="134dp"
android:layout_height="30dp"
android:layout_marginLeft="@dimen/dp10"
android:layout_marginRight="@dimen/dp10"
android:minWidth="134dp">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/blue_rounded_corner_new"
android:text="Centre Square Mall"
android:fontFamily="sans-serif-regular"
android:textAllCaps="false"
android:textColor="@color/beco_black"
android:textSize="13sp"/>
</FrameLayout>
</FrameLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/button_lulu_mall"
android:layout_width="81dp"
android:layout_height="30dp">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/blue_rounded_corner_new"
android:text="Lulu Mall"
android:fontFamily="sans-serif-regular"
android:textAllCaps="false"
android:textColor="@color/beco_black"
android:textSize="13sp"/>
</FrameLayout>
</FrameLayout>
</LinearLayout>
blue_round_corner_new.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="false">
<shape android:shape="rectangle">
<!--apply button background transparent, full opacity-->
<solid android:color="#dedfe0"/>
<corners android:radius="15dp"/>
</shape>
</item >
<item
android:state_pressed="true">
<shape android:shape="rectangle">
<!--apply button background transparent, full opacity-->
<solid android:color="#4990d0"/>
<corners android:radius="15dp"/>
</shape>
</item>
In this code during pressing background color is changing only for a while(not retaining state)
Any one help me. Sorry for my english