2

我正在玩软键盘。

我将此添加到首选项

<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" />

谁能帮我解决这个问题?

4

1 回答 1

0

让它工作

添加到 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);


    }

@onkey

    } 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" />
于 2013-06-02T18:17:43.850 回答