ActionBar and ActionBar

Source: Internet
Author: User

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

SearchManagerPassComponentNameSearchSearchableInfoThe corresponding Component must meet certain conditions:

Another method

SinceSearchManagerYesComponentNameTo obtainSearchableInfoOf 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 ....

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.