0
我想在這個線程使用的解決方案:變化的背景圖像時,點擊/集中不起作用
How to change background image of button when clicked/focused
但出於某種原因沒有什麼作品。當按鈕被點擊時,沒有任何變化。
這是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"/>
這是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>
這是按鈕的onClick():
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
startActivityForResult(intent, ActivityRequestCodes.SELECT_CONTACT);
我在做什麼錯?