這看起來很簡單,但我無法禁用ImageButton
。它繼續接收點擊事件,其外觀不會像標準Button那樣改變。我們有一些similar questions SO,但他們不幫我。禁用ImageButton
即使是一個非常簡單的佈局是這樣的:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageButton
android:id="@+id/btn_call"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:clickable="false"
android:enabled="false"
android:src="@android:drawable/sym_action_call" />
</LinearLayout>
按鈕仍處於啓用狀態,我可以點擊它。
奇怪的是,如果我將ImageButton
更改爲簡單Button
,那麼它的工作方式與預期相同。該按鈕被禁用並且不可點擊。我不明白。有人有想法嗎?
沒有爲我工作。什麼幫助我通過代碼設置禁用狀態: ImageButton mBtnDelayCall =(ImageButton)v.findViewById(R.id.btnCallDelay); mBtnDelayCall.setEnabled(false); – user2924714