Your code is good. You just should add android:clickable="true and android:focusable="true" in your ImageView or combine it with your code like LinearLayout.setClickable(true);.
And maybe your image_selector should look like as follows:
<selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/chiduole_big" android:state_focused="true" /> <item android:drawable="@drawable/chiduole_big" android:state_pressed="true" /> <item android:drawable="@drawable/@drawable/chiduole" /> </selector>
EDIT
I saw what you've done wrong. You've declared android:onClick="true"; what goes inside the onClick is a method not a boolean. So, you can do something like this:
<ImageView android:onClick="MyMethod" android:focusable="true" android:clickable="true" android:id="@+id/iv1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/image_selector" />
And then, in Java you should use the following :
ImageView iv = (ImageView) findViewById(R.id.iv1); iv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MyMethod(v); } }); public void MyMethod(View v) { // Your Code }