android:imeOptions 属性的Values 对应的 EditorInfo Action

android:imeOptions 属性的Values 对应的 EditorInfo Action

 

android:imeOptions  :  安卓 输入法 编辑 设置(Input Method Edit Options

通过布局文件中的 imeOptions 可以控制软件盘右下角的按钮显示为不同按钮。

也正是因此,它与 EditorInfo 的 Action 对应可以实现各种软键盘的功能

 

基本用法:

设置监听器:

EditText.setOnEditorActionListener (this);

需要实现事件回调:  onEditorAction(TextView view, int actionId, KeyEvent event)

@Override
    public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
        LogUtils.d("view = " + view.getId() + "actionId = " + actionId + " -- KeyEvent = " + event);
        switch (actionId) {
            case EditorInfo.IME_ACTION_DONE: // click done
                connectWifi();
                break;
        }
        return false; 
        // 返回 true,保留软键盘。false,隐藏软键盘

    }

 

/**
 * EditorInfo 属性对照:
 * android:imeOptions="actionUnspecified"   -–> EditorInfo.IME_ACTION_UNSPECIFIED // 未审查
 * android:imeOptions="actionNone"          –-> EditorInfo.IME_ACTION_NONE      // 未知
 * android:imeOptions="actionGo"            –-> EditorInfo.IME_ACTION_GO        // 前往
 * android:imeOptions="actionSearch"        -–> EditorInfo.IME_ACTION_SEARCH    // 搜索
 * android:imeOptions="actionSend"          -–> EditorInfo.IME_ACTION_SEND      // 发送
 * android:imeOptions="actionNext"          –-> EditorInfo.IME_ACTION_NEXT      // 下一个
 * android:imeOptions="actionDone"          -–> EditorInfo.IME_ACTION_DONE      // 完成/ 换行
 */
/**
     * EditorInfo属性对照:
     * android:imeOptions="actionUnspecified"   -–> EditorInfo.IME_ACTION_UNSPECIFIED // 未审查
     * android:imeOptions="actionNone"          –-> EditorInfo.IME_ACTION_NONE      // 未知
     * android:imeOptions="actionGo"            –-> EditorInfo.IME_ACTION_GO        // 前往
     * android:imeOptions="actionSearch"        -–> EditorInfo.IME_ACTION_SEARCH    // 搜索
     * android:imeOptions="actionSend"          -–> EditorInfo.IME_ACTION_SEND      // 发送
     * android:imeOptions="actionNext"          –-> EditorInfo.IME_ACTION_NEXT      // 下一个
     * android:imeOptions="actionDone"          -–> EditorInfo.IME_ACTION_DONE      // 完成/ 换行
     */

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值