- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个带有回调实现的 MainActivity:
我还添加了一个 ActionBar SearchView,最后实现了 OnQueryTextListener 以在每个 kb 类型处更改 listFragment 的 listView,但这有效!此外,单击 navDrawer 上的项目会为新类型的 itemsList 生成新的/替换 FragmentList 事务。
现在是问题。ActionBar SearchView 实际上过滤了当前创建的 itemList。
打开/关闭 NavDrawer 是通过覆盖方法中的 invalidateOptionsMenu() 实现的经典“new ActionBarDrawerToggle(){...}”实现的。但是每次打开/关闭抽屉时,此调用都会触发 onQueryTextChange 执行...请参阅日志!我特意生成一个异常以查看这些调用背后的堆栈跟踪:onRestore 实际上是为 SearchView 调用的,我的问题是为什么以及如何避免 SearchView 的这种自动触发?
如果抽屉打开,我可能会检查 onQueryTextChange 以避免重新生成 itemsList。这可能是一个解决方案,但我想知道您的想法以及是否存在其他解决方案。
如果不清楚我可以上传一些代码。日志在这里:
应用程序在开始时显示所有项目(抽屉位置 0)。
10-30 14:34:47.871: V/com.dav.pc.ui.MainActivity(900): MainActivity.initializeDrawer called!
10-30 14:34:47.880: D/com.dav.pc.ui.DrawerListFragment(900): New Drawer Instance!
10-30 14:34:47.900: D/com.dav.pc.ui.MainActivity(900): MainActivity.initializeActivity NewLaunch=Tutti gli elementi
10-30 14:34:47.920: D/com.dav.pc.ui.MainActivity(900): MainActivity.onDrawerItemSelected List selected: ALL
10-30 14:34:47.920: D/com.dav.pc.ui.MainActivity(900): MainActivity.onDrawerItemSelected Transaction Commit
10-30 14:34:47.920: D/com.dav.pc.ui.MainActivity(900): MainActivity.onDrawerItemSelected Label selected: ALL
10-30 14:34:47.930: V/com.dav.pc.ui.DrawerListFragment(900): DrawerListFragment.onCreate() called!
10-30 14:34:47.930: D/com.dav.pc.ui.DrawerListFragment(900): SetPosition onCreate activated_position=-1
10-30 14:34:47.980: V/com.dav.pc.ui.DrawerListFragment(900): DrawerListFragment.onViewCreated() called!
10-30 14:34:47.980: D/com.dav.pc.ui.DrawerListFragment(900): activated_position=0
10-30 14:34:47.980: V/com.dav.pc.ui.DrawerListFragment(900): DrawerListFragment.setSelection() called!
10-30 14:34:47.980: D/com.dav.pc.ui.DrawerListFragment(900): CurrentPosition=0
10-30 14:34:47.980: V/com.dav.pc.ui.DrawerListFragment(900): DrawerListFragment.onActivityCreated() called!
10-30 14:34:47.990: D/com.dav.pc.ui.ItemListFragment(900): ItemListFragment.onCreate Bundle exists
10-30 14:34:47.990: D/com.dav.pc.ui.ItemListFragment(900): Bundle[{list_id=ALL}]
10-30 14:34:47.990: D/com.dav.pc.ui.ItemListFragment(900): Create List ALL (16 items)
10-30 14:34:48.001: I/System.out(900): [mFirstLetters>Item 0,0]
10-30 14:34:48.001: I/System.out(900): [mFirstLetters>Item 1,1]
10-30 14:34:48.001: I/System.out(900): [mFirstLetters>Item 10,2]
10-30 14:34:48.001: I/System.out(900): [mFirstLetters>Item 11,3]
10-30 14:34:48.010: I/System.out(900): [mFirstLetters>Item 12,4]
10-30 14:34:48.010: I/System.out(900): [mFirstLetters>Item 13,5]
10-30 14:34:48.010: I/System.out(900): [mFirstLetters>Item 14,6]
10-30 14:34:48.020: I/System.out(900): [mFirstLetters>Item 15,7]
10-30 14:34:48.020: I/System.out(900): [mFirstLetters>Item 2,8]
10-30 14:34:48.020: I/System.out(900): [mFirstLetters>Item 3,9]
10-30 14:34:48.030: I/System.out(900): [mFirstLetters>Item 4,10]
10-30 14:34:48.040: I/System.out(900): [mFirstLetters>Item 5,11]
10-30 14:34:48.040: I/System.out(900): [mFirstLetters>Item 6,12]
10-30 14:34:48.051: I/System.out(900): [mFirstLetters>Item 7,13]
10-30 14:34:48.051: I/System.out(900): [mFirstLetters>Item 8,14]
10-30 14:34:48.051: I/System.out(900): [mFirstLetters>Item 9,15]
10-30 14:34:48.090: V/com.dav.pc.ui.MainActivity(900): onPostCreate called!
10-30 14:34:48.101: V/com.dav.pc.ui.ItemListFragment(900): ItemListFragment.onResume() called!
10-30 14:34:48.710: V/com.dav.pc.ui.MainActivity(900): MainActivity.onCreateOptionsMenu called!
I type 0 in the searchView:
10-30 14:34:55.421: V/com.dav.pc.ui.MainActivity(900): MainActivity.onQueryTextChange() newText: 0
10-30 14:34:55.440: I/System.out(900): [mFirstLetters>Item 0,0]
10-30 14:34:55.440: I/System.out(900): [mFirstLetters>Item 10,1]
this is another strange behaviour: getItemId in the ItemListAdapter is called 5 times... always, why?
10-30 14:34:55.470: D/com.dav.pc.ui.ItemListAdapter(900): getItemId position: 0
10-30 14:34:55.470: D/com.dav.pc.ui.ItemListAdapter(900): getItemId position: 0
10-30 14:34:55.490: D/com.dav.pc.ui.ItemListAdapter(900): getItemId position: 0
10-30 14:34:55.490: D/com.dav.pc.ui.ItemListAdapter(900): getItemId position: 0
10-30 14:34:55.540: D/com.dav.pc.ui.ItemListAdapter(900): getItemId position: 0
10-30 14:35:01.940: V/com.dav.pc.ui.MainActivity(900): MainActivity.onCreateOptionsMenu called!
onQueryTextChange is fired.
Here my controlled exception, method triggered when Drawer is opened!
This method creates a new ItemListAdapter and passed to the mItemListFragment:
10-30 14:35:02.080: V/com.dav.pc.ui.MainActivity(900): MainActivity.onQueryTextChange() newText: 0
10-30 14:35:02.090: I/System.out(900): [mFirstLetters>Item 0,0]
10-30 14:35:02.100: I/System.out(900): [mFirstLetters>Item 10,1]
10-30 14:35:01.980: W/System.err(900): at com.dav.pc.ui.MainActivity.onQueryTextChange(MainActivity.java:306)
10-30 14:35:01.990: W/System.err(900): at android.widget.SearchView.onTextChanged(SearchView.java:1081)
10-30 14:35:01.990: W/System.err(900): at android.widget.SearchView.access$1900(SearchView.java:90)
10-30 14:35:01.990: W/System.err(900): at android.widget.SearchView$10.onTextChanged(SearchView.java:1536)
10-30 14:35:01.990: W/System.err(900): at android.widget.TextView.sendOnTextChanged(TextView.java:7577)
10-30 14:35:01.990: W/System.err(900): at android.widget.TextView.setText(TextView.java:3259)
10-30 14:35:02.000: W/System.err(900): at android.widget.TextView.setText(TextView.java:3110)
10-30 14:35:02.000: W/System.err(900): at android.widget.EditText.setText(EditText.java:78)
10-30 14:35:02.000: W/System.err(900): at android.widget.TextView.setText(TextView.java:3085)
10-30 14:35:02.000: W/System.err(900): at android.widget.TextView.onRestoreInstanceState(TextView.java:2985)
10-30 14:35:02.000: W/System.err(900): at android.view.View.dispatchRestoreInstanceState(View.java:9876)
10-30 14:35:02.010: W/System.err(900): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2330)
10-30 14:35:02.010: W/System.err(900): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2330)
10-30 14:35:02.010: W/System.err(900): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2330)
10-30 14:35:02.010: W/System.err(900): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2330)
10-30 14:35:02.020: W/System.err(900): at android.view.View.restoreHierarchyState(View.java:9854)
10-30 14:35:02.020: W/System.err(900): at com.android.internal.view.menu.MenuBuilder.restoreActionViewStates(MenuBuilder.java:358)
10-30 14:35:02.020: W/System.err(900): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:412)
10-30 14:35:02.020: W/System.err(900): at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:739)
10-30 14:35:02.030: W/System.err(900): at android.app.Activity.invalidateOptionsMenu(Activity.java:2552)
10-30 14:35:02.030: W/System.err(900): at com.dav.pc.ui.MainActivity$1.onDrawerOpened(MainActivity.java:187)
10-30 14:35:02.030: W/System.err(900): at android.support.v4.widget.DrawerLayout.dispatchOnDrawerOpened(DrawerLayout.java:488)
10-30 14:35:02.040: W/System.err(900): at android.support.v4.widget.DrawerLayout.updateDrawerState(DrawerLayout.java:459)
10-30 14:35:02.040: W/System.err(900): at android.support.v4.widget.DrawerLayout$ViewDragCallback.onViewDragStateChanged(DrawerLayout.java:1355)
...
10-30 14:35:42.040: V/com.dav.pc.ui.MainActivity(900): MainActivity.onCreateOptionsMenu called!
This is my controlled exception, method triggered when Drawer is closed.
Again the execution of the method.
10-30 14:35:42.170: V/com.dav.pc.ui.MainActivity(900): MainActivity.onQueryTextChange() newText: 0
10-30 14:35:42.170: I/System.out(900): [mFirstLetters>Item 0,0]
10-30 14:35:42.180: I/System.out(900): [mFirstLetters>Item 10,1]
10-30 14:35:42.080: W/System.err(900): at com.dav.pc.ui.MainActivity.onQueryTextChange(MainActivity.java:306)
10-30 14:35:42.080: W/System.err(900): at android.widget.SearchView.onTextChanged(SearchView.java:1081)
10-30 14:35:42.090: W/System.err(900): at android.widget.SearchView.access$1900(SearchView.java:90)
10-30 14:35:42.090: W/System.err(900): at android.widget.SearchView$10.onTextChanged(SearchView.java:1536)
10-30 14:35:42.090: W/System.err(900): at android.widget.TextView.sendOnTextChanged(TextView.java:7577)
10-30 14:35:42.090: W/System.err(900): at android.widget.TextView.setText(TextView.java:3259)
10-30 14:35:42.090: W/System.err(900): at android.widget.TextView.setText(TextView.java:3110)
10-30 14:35:42.090: W/System.err(900): at android.widget.EditText.setText(EditText.java:78)
10-30 14:35:42.100: W/System.err(900): at android.widget.TextView.setText(TextView.java:3085)
10-30 14:35:42.100: W/System.err(900): at android.widget.TextView.onRestoreInstanceState(TextView.java:2985)
10-30 14:35:42.100: W/System.err(900): at android.view.View.dispatchRestoreInstanceState(View.java:9876)
10-30 14:35:42.110: W/System.err(900): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2330)
10-30 14:35:42.110: W/System.err(900): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2330)
10-30 14:35:42.110: W/System.err(900): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2330)
10-30 14:35:42.110: W/System.err(900): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2330)
10-30 14:35:42.120: W/System.err(900): at android.view.View.restoreHierarchyState(View.java:9854)
10-30 14:35:42.120: W/System.err(900): at com.android.internal.view.menu.MenuBuilder.restoreActionViewStates(MenuBuilder.java:358)
10-30 14:35:42.120: W/System.err(900): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:412)
10-30 14:35:42.120: W/System.err(900): at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:739)
10-30 14:35:42.130: W/System.err(900): at android.app.Activity.invalidateOptionsMenu(Activity.java:2552)
10-30 14:35:42.130: W/System.err(900): at com.dav.pc.ui.MainActivity$1.onDrawerClosed(MainActivity.java:180)
10-30 14:35:42.140: W/System.err(900): at android.support.v4.widget.DrawerLayout.dispatchOnDrawerClosed(DrawerLayout.java:477)
10-30 14:35:42.140: W/System.err(900): at android.support.v4.widget.DrawerLayout.updateDrawerState(DrawerLayout.java:457)
10-30 14:35:42.140: W/System.err(900): at android.support.v4.widget.DrawerLayout$ViewDragCallback.onViewDragStateChanged(DrawerLayout.java:1355)
....
=========================================================================
This is when instead I select a new ItemDrawer to generate the new list with fragment transaction:
10-30 14:37:47.961: D/com.dav.pc.ui.DrawerListAdapter(900): getItemId position: 5
10-30 14:37:48.100: D/com.dav.pc.ui.DrawerListAdapter(900): getItemId position: 5
10-30 14:37:48.100: D/com.dav.pc.ui.DrawerListAdapter(900): getItemId position: 0
10-30 14:37:48.100: D/com.dav.pc.ui.MainActivity(900): MainActivity.onDrawerItemSelected ListId selected: 4
10-30 14:37:48.100: D/com.dav.pc.ui.MainActivity(900): MainActivity.onDrawerItemSelected ClearSearch
10-30 14:37:48.161: V/com.dav.pc.ui.MainActivity(900): MainActivity.onQueryTextChange() newText:
(I Should avoid this useless generation when clearing the searchText)
10-30 14:37:48.170: I/System.out(900): [mFirstLetters>Item 0,0]
10-30 14:37:48.170: I/System.out(900): [mFirstLetters>Item 1,1]
10-30 14:37:48.170: I/System.out(900): [mFirstLetters>Item 10,2]
10-30 14:37:48.170: I/System.out(900): [mFirstLetters>Item 11,3]
10-30 14:37:48.170: I/System.out(900): [mFirstLetters>Item 12,4]
10-30 14:37:48.181: I/System.out(900): [mFirstLetters>Item 13,5]
10-30 14:37:48.181: I/System.out(900): [mFirstLetters>Item 14,6]
10-30 14:37:48.181: I/System.out(900): [mFirstLetters>Item 15,7]
10-30 14:37:48.181: I/System.out(900): [mFirstLetters>Item 2,8]
10-30 14:37:48.181: I/System.out(900): [mFirstLetters>Item 3,9]
10-30 14:37:48.191: I/System.out(900): [mFirstLetters>Item 4,10]
10-30 14:37:48.191: I/System.out(900): [mFirstLetters>Item 5,11]
10-30 14:37:48.191: I/System.out(900): [mFirstLetters>Item 6,12]
10-30 14:37:48.191: I/System.out(900): [mFirstLetters>Item 7,13]
10-30 14:37:48.191: I/System.out(900): [mFirstLetters>Item 8,14]
10-30 14:37:48.191: I/System.out(900): [mFirstLetters>Item 9,15]
Again my controlled exception to see the stacktrace:
10-30 14:37:48.111: W/System.err(900): at com.dav.pc.ui.MainActivity.onQueryTextChange(MainActivity.java:306)
10-30 14:37:48.111: W/System.err(900): at android.widget.SearchView.onTextChanged(SearchView.java:1081)
10-30 14:37:48.111: W/System.err(900): at android.widget.SearchView.access$1900(SearchView.java:90)
10-30 14:37:48.121: W/System.err(900): at android.widget.SearchView$10.onTextChanged(SearchView.java:1536)
10-30 14:37:48.121: W/System.err(900): at android.widget.TextView.sendOnTextChanged(TextView.java:7577)
10-30 14:37:48.121: W/System.err(900): at android.widget.TextView.setText(TextView.java:3259)
10-30 14:37:48.121: W/System.err(900): at android.widget.TextView.setText(TextView.java:3110)
10-30 14:37:48.121: W/System.err(900): at android.widget.EditText.setText(EditText.java:78)
10-30 14:37:48.121: W/System.err(900): at android.widget.TextView.setText(TextView.java:3085)
10-30 14:37:48.131: W/System.err(900): at android.widget.SearchView.setQuery(SearchView.java:481)
10-30 14:37:48.131: W/System.err(900): at com.dav.pc.ui.MainActivity.onDrawerItemSelected(MainActivity.java:210)
10-30 14:37:48.131: W/System.err(900): at com.dav.pc.ui.DrawerListFragment.onListItemClick(DrawerListFragment.java:153)
10-30 14:37:48.131: W/System.err(900): at android.app.ListFragment$2.onItemClick(ListFragment.java:160)
...
10-30 14:37:48.201: D/com.dav.pc.ui.MainActivity(900): MainActivity.onDrawerItemSelected Transaction Commit
10-30 14:37:48.201: D/com.dav.pc.ui.MainActivity(900): MainActivity.onDrawerItemSelected Label selected: 4
10-30 14:37:48.201: D/com.dav.pc.ui.MainActivity(900): MainActivity.onDrawerItemSelected ClosingDrawer
10-30 14:37:48.201: V/com.dav.pc.ui.DrawerListFragment(900): DrawerListFragment.setSelection() called!
10-30 14:37:48.211: D/com.dav.pc.ui.DrawerListFragment(900): CurrentPosition=5
10-30 14:37:48.211: D/com.dav.pc.ui.DrawerListAdapter(900): getItemId position: 0
10-30 14:37:48.211: D/com.dav.pc.ui.DrawerListAdapter(900): getItemId position: 5
10-30 14:37:48.411: V/com.dav.pc.ui.ItemListFragment(900): ItemListFragment.onPause() called!
10-30 14:37:48.431: D/com.dav.pc.ui.ItemListFragment(900): ItemListFragment.onCreate Bundle exists
10-30 14:37:48.431: D/com.dav.pc.ui.ItemListFragment(900): Bundle[{list_id=4}]
10-30 14:37:48.431: D/com.dav.pc.ui.ItemListFragment(900): Create List 4
(The list 4 contains 6 items, we are in onCreate)
10-30 14:37:48.431: I/System.out(900): [mFirstLetters>Item 0,0]
10-30 14:37:48.431: I/System.out(900): [mFirstLetters>Item 1,1]
10-30 14:37:48.431: I/System.out(900): [mFirstLetters>Item 2,2]
10-30 14:37:48.441: I/System.out(900): [mFirstLetters>Item 3,3]
10-30 14:37:48.441: I/System.out(900): [mFirstLetters>Item 4,4]
10-30 14:37:48.441: I/System.out(900): [mFirstLetters>Item 5,5]
10-30 14:37:48.461: V/com.dav.pc.ui.ItemListFragment(900): ItemListFragment.onResume() called!
10-30 14:37:48.721: V/com.dav.pc.ui.MainActivity(900): MainActivity.onCreateOptionsMenu called!
10-30 14:37:48.811: V/com.dav.pc.ui.MainActivity(900): MainActivity.onQueryTextChange() newText:
10-30 14:37:48.811: I/System.out(900): [mFirstLetters>Item 0,0]
10-30 14:37:48.811: I/System.out(900): [mFirstLetters>Item 1,1]
10-30 14:37:48.821: I/System.out(900): [mFirstLetters>Item 2,2]
10-30 14:37:48.821: I/System.out(900): [mFirstLetters>Item 3,3]
10-30 14:37:48.821: I/System.out(900): [mFirstLetters>Item 4,4]
10-30 14:37:48.821: I/System.out(900): [mFirstLetters>Item 5,5]
10-30 14:37:48.761: W/System.err(900): at com.dav.pc.ui.MainActivity.onQueryTextChange(MainActivity.java:306)
10-30 14:37:48.761: W/System.err(900): at android.widget.SearchView.onTextChanged(SearchView.java:1081)
10-30 14:37:48.761: W/System.err(900): at android.widget.SearchView.access$1900(SearchView.java:90)
10-30 14:37:48.761: W/System.err(900): at android.widget.SearchView$10.onTextChanged(SearchView.java:1536)
10-30 14:37:48.761: W/System.err(900): at android.widget.TextView.sendOnTextChanged(TextView.java:7577)
10-30 14:37:48.761: W/System.err(900): at android.widget.TextView.setText(TextView.java:3259)
10-30 14:37:48.761: W/System.err(900): at android.widget.TextView.setText(TextView.java:3110)
10-30 14:37:48.771: W/System.err(900): at android.widget.EditText.setText(EditText.java:78)
10-30 14:37:48.771: W/System.err(900): at android.widget.TextView.setText(TextView.java:3085)
10-30 14:37:48.771: W/System.err(900): at android.widget.TextView.onRestoreInstanceState(TextView.java:2985)
10-30 14:37:48.771: W/System.err(900): at android.view.View.dispatchRestoreInstanceState(View.java:9876)
10-30 14:37:48.771: W/System.err(900): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2330)
10-30 14:37:48.771: W/System.err(900): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2330)
10-30 14:37:48.781: W/System.err(900): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2330)
10-30 14:37:48.781: W/System.err(900): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2330)
10-30 14:37:48.781: W/System.err(900): at android.view.View.restoreHierarchyState(View.java:9854)
10-30 14:37:48.781: W/System.err(900): at com.android.internal.view.menu.MenuBuilder.restoreActionViewStates(MenuBuilder.java:358)
10-30 14:37:48.781: W/System.err(900): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:412)
10-30 14:37:48.781: W/System.err(900): at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:739)
10-30 14:37:48.791: W/System.err(900): at android.app.Activity.invalidateOptionsMenu(Activity.java:2552)
10-30 14:37:48.791: W/System.err(900): at com.dav.pc.ui.MainActivity$1.onDrawerClosed(MainActivity.java:180)
...
最佳答案
我刚刚找到了一个非常干净的新解决方案,也许其他人对此感兴趣:
在抽屉的打开/关闭实现中,我直接调用 onPrepareOptionsMenu(mMenu)
而不是 invalidateOptionsMenu()
。
如您所见,我使用了创建时保存在 mMenu 中的菜单实例。调用此方法我避免使 searchView 无效,它仍然可能包含一些文本,因此不会被清除。
这里有另一个技巧(总是在 onPrepareOptionsMenu
中)清除/图标化 searchView 我检查当前是否在我的服务类中设置了 searchText:
if (!Service.getInstance().hasSearchText()) {
Log.d(MainActivity.class.getSimpleName(), "onPrepareOptionsMenu Clearing SearchView!");
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setIconified(true);// This also clears the text in SearchView widget
}
关于android - 使用 invalidateOptionsMenu() 打开/关闭 NavDrawer 会导致对 SearchView 和 onQueryTextChange 的 onRestore 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26655992/
我对 QueryTextListener 上的动画搜索 View 感到困惑。当首先创建 Activity 和 fragment 时,它工作得很好。然后我按下主页按钮,打开其他应用程序,在那里做一些工作
我的 SearchView 上有 onQueryTextChange 监听器。 searchView.setOnQueryTextListener(new SearchView.OnQueryText
我正在尝试使用 Sherlock Action Bar 实现 SearchView。我无法获得输入 onQueryTextChange 方法的查询。不确定出了什么问题。 public class Ma
我实现了一个搜索 View ,它从回收站 View 中搜索并相应地更新回收站。当它不匹配任何项目时,我将显示另一个布局“无记录”并将回收站 View 可见性设置为GONE。假设回收站 View 包含一
什么是“节流”onQueryTextChange 以便我的 performSearch() 方法每秒只调用一次而不是每次用户键入时调用的最佳方法? public boolean onQueryText
我有许多 fragment ,它们使用 FragmentStatePagerAdapter 在 2 个选项卡布局中显示在每个 fragment 中都有一个 Recycler View ,我想使用应用栏
这就是我浏览我的应用程序的方式: 用列表打开 fragment 按在搜索 View 中输入的文本过滤列表 点击列表项(列表 fragment 被详细 fragment 替换) 向后导航(详细 frag
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override p
在我的应用程序中使用 SearchView。 无论如何我可以延迟对 onQueryTextChange() 方法的调用。例如,当用户键入一系列字符时,他必须等待此方法被调用。 此等待应该不取决于键入的
SearchView.OnQueryTextListener 方法 onQueryTextChange 在我调用 invalidateOptionsMenu() 后调用 onPrepareOption
这个问题已经有答案了: What is a NullPointerException, and how do I fix it? (12 个回答) 已关闭 7 年前。 我是android开发新手,我已
我有一个带有回调实现的 MainActivity: DrawerListFragment.Callback ItemListFragment.Callbacks SearchView.OnQueryT
我是一名优秀的程序员,十分优秀!