在我的 Motorola Xoom 上测试 Ice Cream Sandwich 版本时,出现了一个问题:尽管我已经实现了事件处理程序,操作栏中的应用程序图标无法点击。只有将 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);
}
}
...