ActionBar and ActionBar
Notes when using ActionBar SearchView:
First, let's talk about the official Guide document of Android. The usage is unclear, probably because it has never been updated.
I followed the document for a moment. The hint cannot jump to the search result Activity either.
StackOverflow has also raised this question. The answer is clear-reference link.
Correct usage notes
SearchManager
PassComponentName
SearchSearchableInfo
The corresponding Component must meet certain conditions:
Another method
SinceSearchManager
YesComponentName
To obtainSearchableInfo
Of course, you can directlyProvide search resultsObtainComponentName
.
SearchManager searchManager = (SearchManager)getSystemService(Context.SEARCH_SERVICE);SearchView searchView = (SearchView)menu.findItem(R.id.action_search).getActionView();ComponentName cn = new ComponentName("com.liangfeizc.catykanji", "com.liangfeizc.catykanji.search.SearchResultActivity");searchView.setSearchableInfo(searchManager.getSearchableInfo(cn));
Tips
The first parameter pkg of the ComponentName constructor is the Package of the Application, not the Package of the target class.
The first parameter ComponentName (String pkg, String cls) isApplication packageNot the package where the activity is.
How does Android make a return activity button on the Actionbar?
Click finish in the event to delete this activity. The previous activity will naturally come out,
Another silly way is to upload an action when A jumps to B, and directly jump to this action when B returns.
There is already an Actionbar at the top. How can I dynamically add an actionbar above?
------ Best solution -------------------------------------------------------- yes, but you must manually call invalidateOptionsMenu () after defining the partition operation attribute in the configuration file to add the menu () to refresh the menu display method, make sure always ------ other solutions ---------------------------------------------------- the column sharding operation attribute refers to manifest. android: uiOptions = "splitActionBarWhenNarrow" in xml is already set, but it still cannot be implemented .. Can you give me a link to the tutorial... ------ Other solutions else // flag = false; // invalidateOptionsMenu (); @ OverridepublicbooleanonPrepareOptionsMenu (Menumenu) {// TODOAuto-generatedmethodstubSystem.out.println ("invalidateOptionsMenu ()"); menu. findItem (R. id. menu_test ). setVisible (flag); returnsuper. onPrepareOptionsMenu (menu);} ------ other solutions ---------------------------------------------------------- No .... This cannot be set ....