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      // 完成/ 换行
     */
发布了46 篇原创文章 · 获赞 74 · 访问量 18万+

猜你喜欢

转载自blog.csdn.net/MLQ8087/article/details/103786799
今日推荐