我正在尝试使用它:在EditText的XML中,我有:
android:imeActionLabel="Search"
android:imeOptions="actionSearch"
但它不起作用。在代码中
search.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
也不起作用。有线索吗?
答案 0 :(得分:1)
试试这个
你的xml文件中的
<EditText
android:id="@+id/rechercheTextView"
android:layout_width="174dp"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:imeOptions="actionSearch"
android:inputType="text"
/>
在你的活动中
EditText rechTxt = (EditText) findViewById(R.id.rechercheTextView);
rechTxt.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
Toast.makeText(getApplicationContext(),"search",Toast.LENGTH_LONG).show();
return true;
}
return false;
}
});