0

提示:它以前和我一起工作,但我不知道发生了什么,当我点击搜索图标时,它没有展开并在 logcat 上给我这个,这也不例外

06-23 06:51:40.316: D/SherlockFragmentActivity(2027): [onMenuItemSelected] featureId: 0, item: Search
06-23 06:51:40.316: D/ActionBarSherlock(2027): [dispatchOptionsItemSelected] item: Search
06-23 06:51:40.316: D/ActionBarSherlock(2027): [callbackOptionsItemSelected] item: Search
06-23 06:51:40.316: D/Watson(2027): [onMenuItemSelected] featureId: 0, item: com.actionbarsherlock.internal.view.menu.MenuItemWrapper@4187d4b0
06-23 06:51:40.316: D/SherlockFragmentActivity(2027): [supportInvalidateOptionsMenu]
06-23 06:51:40.316: D/SherlockFragmentActivity(2027): [invalidateOptionsMenu]
06-23 06:51:40.316: D/ActionBarSherlock(2027): [dispatchInvalidateOptionsMenu]
06-23 06:51:40.438: D/SherlockFragmentActivity(2027): [onCreatePanelMenu] featureId: 0, menu: com.android.internal.view.menu.MenuBuilder@41825968
06-23 06:51:40.438: D/ActionBarSherlock(2027): [dispatchCreateOptionsMenu] menu: com.android.internal.view.menu.MenuBuilder@41825968
06-23 06:51:40.450: D/ActionBarSherlock(2027): [callbackCreateOptionsMenu] menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@41828208
06-23 06:51:40.450: D/Watson(2027): [onCreatePanelMenu] featureId: 0, menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@41828208
06-23 06:51:40.450: D/SherlockFragmentActivity(2027): [getSupportMenuInflater]
06-23 06:51:40.467: D/ActionBarSherlock(2027): [getMenuInflater]
06-23 06:51:40.766: D/Watson(2027): [onCreatePanelMenu] activity create result: true
06-23 06:51:40.766: D/SherlockFragmentActivity(2027): [getSupportMenuInflater]
06-23 06:51:40.766: D/ActionBarSherlock(2027): [getMenuInflater]
06-23 06:51:40.776: D/Watson(2027): [onCreatePanelMenu] fragments create result: false
06-23 06:51:40.776: D/Watson(2027): [onCreatePanelMenu] returning true
06-23 06:51:40.776: D/ActionBarSherlock(2027): [callbackCreateOptionsMenu] returning true
06-23 06:51:40.776: D/ActionBarSherlock(2027): [dispatchCreateOptionsMenu] returning true
06-23 06:51:40.797: D/SherlockFragmentActivity(2027): [onCreatePanelMenu] returning true
06-23 06:51:40.916: D/SherlockFragmentActivity(2027): [onPreparePanel] featureId: 0, view: null, menu: com.android.internal.view.menu.MenuBuilder@41825968
06-23 06:51:40.916: D/ActionBarSherlock(2027): [dispatchPrepareOptionsMenu] menu: com.android.internal.view.menu.MenuBuilder@41825968
06-23 06:51:40.916: D/ActionBarSherlock(2027): [callbackPrepareOptionsMenu] menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@41828208
06-23 06:51:40.916: D/Watson(2027): [onPreparePanel] featureId: 0, view: null menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@41828208
06-23 06:51:40.926: D/Watson(2027): [onPreparePanel] activity prepare result: true
06-23 06:51:40.926: D/Watson(2027): [onPreparePanel] fragments prepare result: false
06-23 06:51:40.926: D/Watson(2027): [onPreparePanel] returning true
06-23 06:51:40.926: D/ActionBarSherlock(2027): [callbackPrepareOptionsMenu] returning true
06-23 06:51:40.926: D/ActionBarSherlock(2027): [dispatchPrepareOptionsMenu] returning true
06-23 06:51:40.926: D/SherlockFragmentActivity(2027): [onPreparePanel] returning true
06-23 06:51:41.016: D/SherlockFragmentActivity(2027): [invalidateOptionsMenu]
06-23 06:51:41.016: D/ActionBarSherlock(2027): [dispatchInvalidateOptionsMenu]
06-23 06:51:41.079: D/SherlockFragmentActivity(2027): [onCreatePanelMenu] featureId: 0, menu: com.android.internal.view.menu.MenuBuilder@41825968
06-23 06:51:41.097: D/ActionBarSherlock(2027): [dispatchCreateOptionsMenu] menu: com.android.internal.view.menu.MenuBuilder@41825968
06-23 06:51:41.097: D/ActionBarSherlock(2027): [callbackCreateOptionsMenu] menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@41828208
06-23 06:51:41.108: D/Watson(2027): [onCreatePanelMenu] featureId: 0, menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@41828208
06-23 06:51:41.108: D/SherlockFragmentActivity(2027): [getSupportMenuInflater]
06-23 06:51:41.108: D/ActionBarSherlock(2027): [getMenuInflater]
06-23 06:51:41.316: D/Watson(2027): [onCreatePanelMenu] activity create result: true
06-23 06:51:41.316: D/SherlockFragmentActivity(2027): [getSupportMenuInflater]
06-23 06:51:41.316: D/ActionBarSherlock(2027): [getMenuInflater]
06-23 06:51:41.316: D/Watson(2027): [onCreatePanelMenu] fragments create result: false
06-23 06:51:41.316: D/Watson(2027): [onCreatePanelMenu] returning true
06-23 06:51:41.316: D/ActionBarSherlock(2027): [callbackCreateOptionsMenu] returning true
06-23 06:51:41.316: D/ActionBarSherlock(2027): [dispatchCreateOptionsMenu] returning true
06-23 06:51:41.316: D/SherlockFragmentActivity(2027): [onCreatePanelMenu] returning true
06-23 06:51:41.340: D/SherlockFragmentActivity(2027): [onPreparePanel] featureId: 0, view: null, menu: com.android.internal.view.menu.MenuBuilder@41825968
06-23 06:51:41.352: D/ActionBarSherlock(2027): [dispatchPrepareOptionsMenu] menu: com.android.internal.view.menu.MenuBuilder@41825968
06-23 06:51:41.352: D/ActionBarSherlock(2027): [callbackPrepareOptionsMenu] menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@41828208
06-23 06:51:41.352: D/Watson(2027): [onPreparePanel] featureId: 0, view: null menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@41828208
06-23 06:51:41.388: D/Watson(2027): [onPreparePanel] activity prepare result: true
06-23 06:51:41.388: D/Watson(2027): [onPreparePanel] fragments prepare result: false
06-23 06:51:41.388: D/Watson(2027): [onPreparePanel] returning true
06-23 06:51:41.388: D/ActionBarSherlock(2027): [callbackPrepareOptionsMenu] returning true
06-23 06:51:41.388: D/ActionBarSherlock(2027): [dispatchPrepareOptionsMenu] returning true
06-23 06:51:41.388: D/SherlockFragmentActivity(2027): [onPreparePanel] returning true
06-23 06:51:41.406: D/ActionBarSherlock(2027): [callbackOptionsItemSelected] returning false
06-23 06:51:41.406: D/ActionBarSherlock(2027): [dispatchOptionsItemSelected] returning false
06-23 06:51:41.406: D/SherlockFragmentActivity(2027): [onMenuItemSelected] returning false
06-23 06:51:41.536: I/Choreographer(2027): Skipped 125 frames!  The application may be doing too much work on its main thread.

这是搜索的菜单 xml

<item
        android:id="@+id/menu_search"
        android:actionViewClass="android.widget.SearchView"
        android:icon="@drawable/action_search"
        android:showAsAction="ifRoom|collapseActionView"
        android:title="@string/menu_search"/>
4

1 回答 1

0

这是因为功能

supportInvalidateOptionsMenu();
invalidateOptionsMenu();

在 onOptionsMenuClosed()、OnOptionsItemSelectedListener()、onOptionsItemSelected() 中调用

我将它们从这些函数中删除并仅将它们放在 OnCreate() 方法中,这些函数的目的是声明选项菜单已更改,因此应重新创建。下次需要显示时会调用 onCreateOptionsMenu(Menu) 方法。

于 2013-06-23T06:54:27.767 回答