Android 4.0/ICS - 操作栏上的应用程序图标无法点击

SZH*_*SZH 11 java android xoom android-4.0-ice-cream-sandwich android-actionbar

出于某种原因,在使用Ice Cream Sandwich在我的Motorola Xoom上进行测试时,即使我已经实现了事件处理程序,操作栏中的应用程序图标也不可点击.这仅在将targetSdkVersion更改为15后才会发生.如果它是13,它仍然是可点击的,即使在ICS上也是如此.为什么会发生这种情况,如何让它像按钮一样点击?我搜索了文档,找不到任何东西.

谢谢.

更新:这是我的代码:

AndroidManifest.xml中:

...
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" />
<application android:icon="@drawable/icon" android:label="@string/app_name"
    android:theme="@style/android:Theme.Holo.Light">
...
Run Code Online (Sandbox Code Playgroud)

BaseActivity.java(我的活动都继承自这个类:

...
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            // app icon in action bar clicked; go home
            Intent intent = new Intent(this, MainActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
...
Run Code Online (Sandbox Code Playgroud)

SZH*_*SZH 25

我在http://developer.android.com/guide/topics/ui/actionbar.html的文档中找到了它:

注意:如果您使用该图标导航到主页活动,请注意从Android 4.0(API级别14)开始,您必须通过调用setHomeButtonEnabled(true)显式启用该图标作为操作项(在以前的版本中,默认情况下,图标已启用为操作项).