转载请注明出处:
http://blog.youkuaiyun.com/user11223344abc?viewmode=contents
出自【蛟-blog】
若想改变键盘回车键的提示信息(本文以“搜索”为例),需要知道有2中途径和一个注意点。
1.途径一,java代码设置
edit.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
2.途径二,xml内属性设置
<EditText
android:background="@android:color/white"
android:id="@+id/edit"
android:imeOptions="actionSearch"
android:layout_width="80dp"
android:layout_height="40dp"
android:layout_centerInParent="true" />
3.一个注意点
光是这样写了是无法生效的,需要其他一些属性来"激活"该项设置
我所知道的有:
android:singleLine="true"
android:inputType="text"
4.顺道说一下改了信息之后的点击事件监听
edit.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_DEL && event.getAction() == KeyEvent.ACTION_DOWN) {
}
return false;
}
});