I am trying to use the solutions in this thread:
How to change background image of button when clicked/focused
But for some reason nothing works. When the button is clicked nothing changes.
This is the button in activity_main.xml:
<ImageButton
android:id="@+id/selectContactBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="contacts"
android:textSize="18sp"
android:layout_above="@+id/selectMediaBtn"
android:layout_alignRight="@+id/selectMediaBtn"
android:layout_alignEnd="@+id/selectMediaBtn"
android:background="@drawable/select_contact"/>
And this is the select_contact.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/blocked_mc" />
<item android:drawable="@drawable/select_contact" /> //means normal
</selector>
And this is the button's onClick():
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
startActivityForResult(intent, ActivityRequestCodes.SELECT_CONTACT);
What am I doing wrong?