2012-07-01 83 views
2

我想改變輸入按鈕的名稱(按鈕圖像中圈出)來搜索改變返回鍵

enter image description here

所以我用

<EditText 
       android:imeOptions="actionSearch" 
       android:imeActionLabel="Search" 


       android:id="@+id/et_PatientID" 

       android:layout_width="400dip" 
       android:layout_height="50dip" 
       android:layout_toRightOf="@id/tv_patientID" 
       android:background="@android:drawable/editbox_background" /> 

但事與願違工作

+0

嘗試添加安卓的inputType =「文本」,看到更新的答案 –

回答

4

android:imeOptions="actionSearch"android:inputType="text"添加到您的EditText視圖

還添加了編輯的動作監聽

editText.setOnEditorActionListener(new TextView.OnEditorActionListener() { 
    @Override 
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { 
     if (actionId == EditorInfo.IME_ACTION_SEARCH) { 
      performSearch(); 
      return true; 
     } 
     return false; 
    } 
}); 

<EditText 
      android:id="@+id/et_PatientID" 
      android:inputType="text" 
      android:layout_width="400dip" 
      android:layout_height="50dip" 
      android:layout_toRightOf="@id/tv_patientID" 
      android:background="@android:drawable/editbox_background" 
      android:imeOptions="actionSearch" 
      android:imeActionLabel="Search" /> 
+0

我沒有,但它不工作 – AMH

+0

@AMH刪除imeOptions =「acionUnspecified」 –

+0

@AMH至極的android版本是否使用 –