0
如果我使用:用以下日誌ActionBarSherlock崩潰在Android 4.x的
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getSupportMenuInflater().inflate(R.menu.main_menu, menu);
com.actionbarsherlock.widget.SearchView searchView = new com.actionbarsherlock.widget.SearchView(Activity_TimetablePager.this);
...
系統崩潰:
06-22 18:18:23.384: D/SherlockFragmentActivity(3613): [onCreatePanelMenu] featureId: 0, menu: [email protected]
06-22 18:18:23.384: D/ActionBarSherlock(3613): [dispatchCreateOptionsMenu] menu: [email protected]
06-22 18:18:23.384: D/ActionBarSherlock(3613): [callbackCreateOptionsMenu] menu: [email protected]
06-22 18:18:23.384: D/Watson(3613): [onCreatePanelMenu] featureId: 0, menu: [email protected]
06-22 18:18:23.384: D/SherlockFragmentActivity(3613): [getSupportMenuInflater]
06-22 18:18:23.384: D/ActionBarSherlock(3613): [getMenuInflater]
06-22 18:18:23.384: D/ActionBarSherlock(3613): [getActionBar]
06-22 18:18:23.384: D/AndroidRuntime(3613): Shutting down VM
06-22 18:18:23.384: W/dalvikvm(3613): threadid=1: thread exiting with uncaught exception (group=0xaecd1908)
06-22 18:18:23.384: E/AndroidRuntime(3613): FATAL EXCEPTION: main
06-22 18:18:23.384: E/AndroidRuntime(3613): android.view.InflateException: Binary XML file line #29: Error inflating class <unknown>
06-22 18:18:23.384: E/AndroidRuntime(3613): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
06-22 18:18:23.384: E/AndroidRuntime(3613): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
能正常工作在Android 2.3,但不支持4.x我在使用ActionBarSherlock 4.3.1,在這種情況下在viewPager活動。這是一個已知的問題?
(目前我有一個替代方案,我用的是默認的Android搜索查看在4.x版)
基本上我得到了同樣的結果。在你的示例代碼中,searchView = null,而searchItem仍然可以。因此,searchItem.getActionView似乎是問題所在。 –
你的評論導致另一個類似的問題。如果我在清單活動定義中使用:android:theme =「@ style/Theme.Sherlock.Light」,那麼它就起作用了。但如果我使用樣式: