关于android软键盘enter键的替换与事件监听
软件盘的界面替换只有一个属性android:imeOptions,这个属性的可以取的值有 normal,actionUnspecified,actionNone,actionGo,actionSearch,actionSend,actionNext,actionDone, 例如当值为actionNext时enter键外观变成一个向下箭头,而值为actionDone时enter键外观则变成了“完成”两个字。
我们也可以重写enter的事件,方法如下
- TextView editText = new TextView(this);
- editText.setOnEditorActionListene(
- newTextView.OnEditorActionListener() {
- public boolean onEditorAction(TextView v, int actionId,
- KeyEvent event){
- if (actionId == EditorInfo.IME_ACTION_SEND)
- {
- // 在这里编写自己想要实现的功能
- }
- return false;
- }
- });
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步