Rah*_*rma 202
在您的布局设置输入方法到搜索选项
<EditText
android:imeOptions="actionSearch"
android:inputType="text"/>
Run Code Online (Sandbox Code Playgroud)
并在java代码中使用
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;
}
});
Run Code Online (Sandbox Code Playgroud)
suc*_*nil 80
使用该代码编辑EditText属性
<EditText android:imeOptions="actionSearch" />
Run Code Online (Sandbox Code Playgroud)
然后在你的java代码中执行此操作:
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;
}
});
Run Code Online (Sandbox Code Playgroud)
Suj*_*ana 16
android:singleLine="true"
android:imeOptions="actionSearch"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
80267 次 |
| 最近记录: |