For Android search, change the Enter key on the keyboard to search

Source: Internet
Author: User

After entering the content on editview, you can directly click the search key on the keyboard [adapted from the previous enter key]

The procedure is as follows:

1. Modify the editview attribute: Android: imeoptions = "actionsearch". When this editview gets the focus, change the "enter" key to "Search"

Android: singleline = "true" or press enter to search for a new line.

2. Set the keyboard listening for editview

Et_search_content.setonkeylistener (New onkeylistener () {// After the input, press the search key on the disk. [change the Enter key to the search key]

Public Boolean onkey (view V, int keycode, keyevent event ){
If (keycode = keyevent. keycode_enter) {// modify the Enter key function
// Hide the keyboard first
(Inputmethodmanager) getsystemservice (input_method_service ))
. Hidesoftinputfromwindow (
Findprojectactivity. This
. Getcurrentfocus ()
. Getwindowtoken (),
Inputmethodmanager. hide_not_always );

// Jump to the search result page
B = new bundle ();
B. putstring ("keyword", "". Equals (et_search_content.gettext (). tostring ())? "0": et_search_content.gettext (). tostring ());
B. putstring ("city", "". Equals (TV _province1.gettext (). tostring ())? "0": TV _province1.gettext (). tostring ());
B. putstring ("industry", "". Equals (TV _hangye1.gettext (). tostring ())? "0": TV _hangye1.gettext (). tostring ());
B. putstring ("fund", "". Equals (et_money.gettext (). tostring ())? "0": et_money.gettext (). tostring ());
If (TV _time.gettext (). Equals ("within one week ")){
B. putstring ("time", "W ");
}
If (TV _time.gettext (). Equals ("January ")){
B. putstring ("time", "M ");
}
If (TV _time.gettext (). Equals ("within six months ")){
B. putstring ("time", "hy ");
}
If (TV _time.gettext (). Equals ("one year ")){
B. putstring ("time", "Y ");
}

Utils. startactivity (findprojectactivity. This,
Projectlistactivity. Class, B );
}
Return false;
}
});

 

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.