2011-12-20 44 views
0

我有以下为编辑文本:安卓:搜索按钮,而不是输入的EditText

<EditText 
     android:paddingTop="10dip" android:paddingBottom="10dip" 
android:paddingRight="10dip" android:paddingLeft="10dip" 
     android:id="@+id/myBookSearchEditTextId" 
     android:layout_width="200dp" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:background="@color/white" 
     android:saveEnabled="true" 
     android:scrollHorizontally="true" 
     android:selectAllOnFocus="true" 
     android:imeOptions="actionSearch" 
     android:text="Search" 
     android:textColor="@color/black" > 

     <requestFocus /> 
    </EditText> 

为什么我仍然看到键盘的回车键,而不是搜索键上?

我发现东西 - 它似乎在使用softkeyboard它具有porblem ... 正如在网络上找到像 - 也许需要得到InputmethodManager在onclick上的EditText:

...Onclick(...) 
{ 
    InputmethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); 
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0); 
} 
+0

你在设备上还是在仿真器上测试?什么是requestFocus在这里? – Sujit 2011-12-20 09:19:37

+0

你正在使用哪个api级别? – 2011-12-20 09:19:54

+0

在设备上测试。在设备上测试时 - 项目设置的API级别是否重要?它设置为Min API级别8. – Yoav 2011-12-20 09:20:47

回答

0

尝试。 。editTx.setImeActionLabel(“Search”,EditorInfo.IME_ACTION_SEARCH);而不是在布局xml中。

0

我的搜索图标直到添加inputType才显示。

上述这些问题都需要:

机器人:imeOptions = “actionSearch”

安卓的inputType = “文本”