Android ActionBar searview change default search button picture

Source: Internet
Author: User

Do search images found Searchview system display the default search button is just a small arrow, look very ugly, want to change this icon. So in StackOverflow this site found the answer, directly on the code:

     @Override public    void Oncreateoptionsmenu (Menu menu, Menuinflater inflater) {        inflater.inflate (r.menu.event_ History, menu);        MenuItem search = Menu.finditem (r.id.search_event);        Search.collapseactionview ();        Is the search box default expansion//        Search.expandactionview ();        Searchview Searchview = (searchview) search.getactionview ();        Show Search Confirmation button        searchview.setsubmitbuttonenabled (true);        Find the search button corresponding to the linearlayout        int searchplateid = Searchview.getcontext (). Getresources (). Getidentifier ("Android:id /submit_area ", NULL, NULL);        LinearLayout searchplate = (linearlayout) Searchview.findviewbyid (Searchplateid);        Get the ImageView of the search icon so you can modify the picture        ((ImageView) searchplate.getchildat (0)). Setimageresource (R.drawable.audio_ BAR_SRC);          Searchview.setonquerytextlistener (this);        Super.oncreateoptionsmenu (menu, Inflater);    }


Android ActionBar Searview Change the default search button picture

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.