On Click of of a ImageView Change the Background of the Layout Android -


on click of imageview want change background of layout .how can have created selector

<?xml version="1.0" encoding="utf-8"?>      <selector          xmlns:android="http://schemas.android.com/apk/res/android">             <item                      android:drawable="@drawable/blue_bar"                      android:state_pressed="true"/>              <item                      android:drawable="@drawable/gray_bg"/>     </selector> 

xml is

 <imageview             android:id="@+id/bookbutton"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:gravity="center"             android:onclick="reviewitineary"             android:src="@drawable/book" /> 

 mylayout = (relativelayout) findviewbyid(r.layout.main);//your layout instance  imageview=(imageview)findviewbyid(r.id.bookbutton);   imageview.setonclicklistener(new onclicklistener()      {     @override      public void onclick(view v) {      // todo auto-generated method stub                    myimgview.setimageresource(r.drawable. blue_bar);                      mylayout.setimageresource(r.drawable. blue_bar);                }      });    } 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -