Android--searchbox

Source: Internet
Author: User

  Public voidOpenSearch () {Search=(SearchBox) Findviewbyid (R.id.searchbox); Search.enablevoicerecognition ( This); Search.revealfrommenuitem (R.id.iv_search, This); //Showing from a MenuItem click on a menu Item and show it here         for(intx = 0; x < 10; X + +) {searchresult option=NewSearchResult ("Result" +integer.tostring (x), Getresources (). getdrawable (R.mipmap.ic_launcher));        search.addsearchable (option); } search.setsearchlistener (NewSearchbox.searchlistener () {//Just click the search button to call@Override Public voidonsearchopened () {Display ("Onsearchopened"); }            //Click the Eject button to invoke@Override Public voidonsearchclosed () {Display ("Onsearchclosed was called.");            Closesearch (); }            //Listen to the input box and call it as soon as it changes@Override Public voidonsearchtermchanged (String term) {display ("Onsearchtermchanged was called."); } @Override Public voidOnsearch (String searchterm) {//Display (searchterm + "searched");Display ("Onsearch is called"); }            //Click to display the content, be called@Override Public voidOnresultclick (SearchResult result) {display ("Onresultclick was called."); }            //after the search is over. has not been called. @Override Public voidonsearchcleared () {Display ("Onsearchcleared was called.");    }        }); }



@Override
protected void Onactivityresult (int requestcode, int resultcode, Intent data) {
if (Requestcode = = 1234 && ResultCode = = RESULT_OK) {
arraylist<string> matches = data
. Getstringarraylistextra (Recognizerintent.extra_results);
Search.populateedittext (matches.get (0));
}
Super.onactivityresult (Requestcode, ResultCode, data);
}

Hide it.
protected void Closesearch () {
Search.hidecircularly (this);
}

Android--searchbox

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.