2013-05-31 11 views
2

我玩弄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" /> 

字符串任何人都可以幫我這個?

回答

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); 


    } 

@安其

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