Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.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
Java 使用“我的键盘中的编辑文本”中的字符串_Java_Android_Android Softkeyboard - Fatal编程技术网

Java 使用“我的键盘中的编辑文本”中的字符串

Java 使用“我的键盘中的编辑文本”中的字符串,java,android,android-softkeyboard,Java,Android,Android Softkeyboard,我在玩软键盘 我将此添加到首选项中 <EditTextPreference android:name="Custom ket" android:summary="Set up a custom key" android:title="Custom key" android:key="Customkey" /> 我必须做什么才能在中使用此字符串 <Key android:keyOutputText="string" android:keyLabel="custom key"

我在玩软键盘

我将此添加到首选项中

<EditTextPreference
android:name="Custom ket"
android:summary="Set up a custom key"
android:title="Custom key"
android:key="Customkey" />

我必须做什么才能在中使用此字符串

<Key android:keyOutputText="string" android:keyLabel="custom key" />

有人能帮我解决这个问题吗?

开始工作了

添加到SoftKeyboard.java

private void handleCustomkey() {
    SharedPreferences app_preferences = 
            getSharedPreferences("com.keyboard.test_preferences", Context.MODE_PRIVATE);

    String ck = app_preferences.getString("Customkey", "0");
    this.getCurrentInputConnection().commitText(ck, 1);


    }
@安基

    } else if (primaryCode == LatinKeyboardView.KEYCODE_CUSTOMKEY) {
        handleCustomkey();
        return;
添加到LatinKeyboardView.java

static final int KEYCODE_CUSTOMKEY = -120;
添加到qwerty.xml

    <Key android:codes="-120" android:keyLabel="Custom" />

添加到settings.xml

<EditTextPreference
android:name="Custom key"
android:summary="Set up a custom key"
android:title="Custom key"
android:key="Customkey" />