Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android自定义键盘-如何获取浏览器输入类型?_Android_Android Softkeyboard - Fatal编程技术网

Android自定义键盘-如何获取浏览器输入类型?

Android自定义键盘-如何获取浏览器输入类型?,android,android-softkeyboard,Android,Android Softkeyboard,我正在尝试为每种输入类型(如简单文本、数字、电子邮件、URL地址等)制作一个自定义Android键盘(min API 16)。我不明白的是如何获得浏览器URL文本编辑器的输入类型,这样我就可以制作一个带有“访问”按钮的键盘 @Override public void onStartInput(EditorInfo attribute, boolean restarting) { super.onStartInput(attribute, restarting); switch

我正在尝试为每种输入类型(如简单文本、数字、电子邮件、URL地址等)制作一个自定义Android键盘(min API 16)。我不明白的是如何获得浏览器URL文本编辑器的输入类型,这样我就可以制作一个带有“访问”按钮的键盘

@Override public void onStartInput(EditorInfo attribute, boolean restarting) {
    super.onStartInput(attribute, restarting);

    switch (attribute.inputType & InputType.TYPE_MASK_CLASS) {
        case InputType.TYPE_CLASS_NUMBER:
        case InputType.TYPE_CLASS_DATETIME:
        case InputType.TYPE_CLASS_PHONE:
            mCurKeyboard = symKeyboard_1;
            break;
        case InputType.TYPE_TEXT_VARIATION_URI:
        case InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT:
        case InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS:
        case InputType.TYPE_TEXT_VARIATION_EMAIL_SUBJECT:
        case InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS:
        case InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS:
            mCurKeyboard = webKeyboard;
            Log.d("debug", "web keyboard");
            break;
        case InputType.TYPE_CLASS_TEXT:
            mCurKeyboard = myKeyboard;
            Log.d("debug", "text");
            break;
        default:
            mCurKeyboard = myKeyboard;
            Log.d("debug", "default");
            break;
    }
}
但我还是得到了InputType的
InputType.TYPE\u CLASS\u TEXT

我想我已经尝试了几乎所有的
InputType
,但是没有一个可以确定我何时在URL文本框中键入内容。我需要一个解决方案来找到URL文本编辑器的输入类型

顺便问一下:如何通过传递给
getCurrentInputConnection().sendKeyEvent()
KeyEvent
对浏览器执行
Access
Go
操作

稍后编辑。解决方案:

@Override public void onStartInput(EditorInfo attribute, boolean restarting) {
    super.onStartInput(attribute, restarting);

    switch (attribute.inputType & InputType.TYPE_MASK_CLASS) {
        case InputType.TYPE_CLASS_NUMBER:
        case InputType.TYPE_CLASS_DATETIME:
        case InputType.TYPE_CLASS_PHONE:
            currentKeyboard = numericKeyboard;
            break;
        case InputType.TYPE_CLASS_TEXT:
            int webInputType = attribute.inputType & InputType.TYPE_MASK_VARIATION;

            if (webInputType == InputType.TYPE_TEXT_VARIATION_URI ||
                    webInputType == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT ||
                    webInputType == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
                    || webInputType == InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS) {
                currentKeyboard = webKeyboard;
            }else{
                currentKeyboard = latinKeyboard;
            }
            break;
        default:
            currentKeyboard = latinKeyboard;
            break;
    }
}
@ray20表示,处理“访问”、“转到”操作的答案是,这是针对其他编辑器操作的:

private void handleAction(){
    EditorInfo curEditor = getCurrentInputEditorInfo();
    switch (curEditor.imeOptions & EditorInfo.IME_MASK_ACTION){
        case EditorInfo.IME_ACTION_DONE:
            getCurrentInputConnection().performEditorAction(EditorInfo.IME_ACTION_DONE);
            break;
        case EditorInfo.IME_ACTION_GO:
            getCurrentInputConnection().performEditorAction(EditorInfo.IME_ACTION_GO);
            break;
        case EditorInfo.IME_ACTION_NEXT:
            getCurrentInputConnection().performEditorAction(EditorInfo.IME_ACTION_NEXT);
            break;
        case EditorInfo.IME_ACTION_SEARCH:
            getCurrentInputConnection().performEditorAction(EditorInfo.IME_ACTION_SEARCH);
            break;
        case EditorInfo.IME_ACTION_SEND:
            getCurrentInputConnection().performEditorAction(EditorInfo.IME_ACTION_SEND);
            break;
        default:
            handleClose(); //method that hides the keyboard with no action performed
            break;
    }
}

执行围棋动作

getCurrentInputConnection().performEditorAction(EditorInfo.IME\u ACTION\u GO)