在菜单项中使用 actionLayout 时,不会调用 onOptionsItemSelected 方法。我错过了什么,还是 SherlockActionBar 的已知问题?
活动
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.article, menu);
super.onCreateOptionsMenu(menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Log.d(TAG, "onOptionsItemSelected()");
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.menu_item_comment:
return true;
default:
return super.onOptionsItemSelected(item);
}
}
菜单
<item android:id="@+id/menu_item_comment"
android:showAsAction="ifRoom"
android:actionLayout="@layout/action_bar_comment_layout"/>