这是SherlockActionBar
示例,它使用静态附件,我运行到ICE_CREAM_SANDWICH
设备,但onOptionsItemSelected
没有调用方法!
多余部分代码删掉,3.x和2.x版本试过没问题,帮帮我~~
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(SampleList.THEME); // Used for theme switching in samples
super.onCreate(savedInstanceState);
mSherlock
.setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
mSherlock.setContentView(R.layout.text);
((TextView) findViewById(R.id.text))
.setText(R.string.static_attach_content);
}
@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
return mSherlock.dispatchCreateOptionsMenu(menu);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Used to put dark icons on light action bar
boolean isLight = SampleList.THEME == R.style.Theme_Sherlock_Light;
menu.add("Save")...
menu.add("Search")...
menu.add("Refresh")...
return true;
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (mSherlock.dispatchKeyEvent(event)) {
return true;
}
return super.dispatchKeyEvent(event);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Log.i("", "on options item selected!!!!!!!!!!!!!!!!");
Toast.makeText(this, item.toString(), Toast.LENGTH_SHORT).show();
return true;
}
}