From: rmceoin Date: Sun, 25 Oct 2009 21:12:08 +0000 (+0000) Subject: OI Safe: soft keyboard on Search now offers a search button X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=127da2cbe93966ba9f311aec75a94c762ded5e8c;p=android-vcpass-oisafe OI Safe: soft keyboard on Search now offers a search button git-svn-id: http://openintents.googlecode.com/svn/trunk/Safe@2348 72b678ce-9140-0410-bee8-679b907dd61a --- diff --git a/res/layout/search.xml b/res/layout/search.xml index d9a5f9b..83d6126 100644 --- a/res/layout/search.xml +++ b/res/layout/search.xml @@ -29,6 +29,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="textFilter" + android:imeOptions="actionSearch" + android:imeActionLabel="@string/search" android:maxLength="50" android:hint="@string/search_hint" android:layout_weight="1"/> diff --git a/src/org/openintents/safe/Search.java b/src/org/openintents/safe/Search.java index ebb2fe9..388200b 100644 --- a/src/org/openintents/safe/Search.java +++ b/src/org/openintents/safe/Search.java @@ -33,10 +33,14 @@ import android.os.Handler; import android.os.Message; import android.util.Log; import android.view.View; +import android.view.KeyEvent; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; +import android.widget.TextView; import android.widget.Toast; public class Search extends ListActivity { @@ -110,7 +114,21 @@ public class Search extends ListActivity { searchThreadStart(); } }); - + + etSearchCriteria.setOnEditorActionListener(new TextView.OnEditorActionListener() { + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_SEARCH) { + InputMethodManager imm = + (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); + imm.toggleSoftInput(0, 0); + searchCriteria = etSearchCriteria.getText().toString().trim().toLowerCase(); + searchThreadStart(); + return true; + } + return false; + } + }); + restoreMe(); }