{"id":967,"date":"2023-03-11T19:51:00","date_gmt":"2023-03-11T11:51:00","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=967"},"modified":"2023-04-29T13:28:36","modified_gmt":"2023-04-29T05:28:36","slug":"android-edittext-adds-android-imeoptions-actionsearch-settings-with-search-button-on-the-pop-up-keyboard","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/11\/android-edittext-adds-android-imeoptions-actionsearch-settings-with-search-button-on-the-pop-up-keyboard\/","title":{"rendered":"Android EditText\u6dfb\u52a0android:imeOptions=&#8221;actionSearch&#8221;\u8bbe\u7f6e\u5f39\u51fa\u7684\u952e\u76d8\u4e2d\u5e26\u6709\u641c\u7d22\u6309\u94ae"},"content":{"rendered":"<h2>XML\u5e03\u5c40<\/h2>\n<pre><code class=\"language-xml\">android:imeOptions=&quot;actionSearch&quot;\nandroid:singleLine=&quot;true&quot;  \/\/\u5fc5\u9700\uff0c\u5426\u5219\u8bbe\u7f6eactionSearch\u4e0d\u751f\u6548<\/code><\/pre>\n<p><!-- more --><\/p>\n<pre><code class=\"language-xml\">&lt;me.yezhou.lib.ui_widget.common.ThemedEditText\n    android:id=&quot;@+id\/et_search_input&quot;\n    android:layout_width=&quot;match_parent&quot;\n    android:layout_height=&quot;30dp&quot;\n    android:layout_gravity=&quot;center&quot;\n    android:background=&quot;@drawable\/selector_button_rect_white_blue&quot;\n    android:gravity=&quot;center_vertical&quot;\n    android:hint=&quot;@string\/search_input_hint&quot;\n    android:imeOptions=&quot;actionSearch&quot;\n    android:singleLine=&quot;true&quot;\n    android:paddingLeft=&quot;30dp&quot;\n    android:paddingRight=&quot;10dp&quot;\n    android:textColorHint=&quot;#aaaaaa&quot;\n    android:textSize=&quot;13sp&quot;\n    \/&gt;<\/code><\/pre>\n<h2>\u8bbe\u7f6eOnEditorActionListener\u76d1\u542c<\/h2>\n<pre><code class=\"language-java\">mEtSearchInput.setFocusable(true);\nmEtSearchInput.setFocusableInTouchMode(true);\nmEtSearchInput.requestFocus();\nTimer timer = new Timer();\ntimer.schedule(new TimerTask() {\n    public void run() {\n        InputMethodManager inputManager = (InputMethodManager) mEtSearchInput.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);\n        inputManager.showSoftInput(mEtSearchInput, 0);\n    }\n}, 1000);\n\nmEtSearchInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {\n    @Override\n    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {\n        KeyBoardUtil.hideKeyBoard(mEtSearchInput);\n        if (actionId == EditorInfo.IME_ACTION_SEARCH) {\n\n        }\n        return true;\n    }\n});<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>XML\u5e03\u5c40 android:imeOptions=&quot;actionSearch&quot; andro [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[119],"tags":[264],"class_list":["post-967","post","type-post","status-publish","format-standard","hentry","category-android-ui","tag-edittext"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/967","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=967"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/967\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=967"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=967"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=967"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}