Search code examples
androidandroid-actionbaractionbarsherlock

Is it possible to make an Action "unclickable"?


I'm using the ActionBarSherlock library for my application for API level 10. I was wondering if it is possible to have an Action icon that does not respond when it has been clicked.

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/mainTopBluetoothState"
        android:icon="@drawable/bt_not_connected"
        android:orderInCategory="0"
        android:clickable="false"
        android:showAsAction="ifRoom" />

    <item android:id="@+id/mainTopAppState"
        android:title="App State"
        android:orderInCategory="1"
        android:showAsAction="ifRoom" />

</menu>

The android:clickable="false" does not produce an error, but the Action still reacts when pressed while the application is running.


Solution

  • Try android:enabled or setEnabled() at runtime on the MenuItem.