edittext 软键盘文字根据需求更改 在xml中更改imeOptions 属性
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionSearch"
android:inputType="text"
android:hint="搜索"/>
//
manager = (InputMethodManager) getActivity().getSystemService(INPUT_METHOD_SERVICE);
etSearch.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
//先隐藏键盘
if (manager.isActive()) {
manager.hideSoftInputFromWindow(etSearch.getApplicationWindowToken(), 0);
}
}
return false;
}
});
android:imeOptions=“actionSend”
软键盘文字更改为 发送
android:imeOptions=“actionNext”
软键盘文字更改为 下一步
android:imeOptions=“actionGo”
软键盘文字更改为 开始
android:imeOptions=“actionDone”
隐藏软键盘