出于某种原因,在我的带有冰淇淋三明治的 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">
...
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);
}
}
...