2012-04-17 33 views
1

Androidカスタムキーボードを開発中です。私はandroid.view.inputmethod.InputMethodSubtypeを私のコードにインポートしましたが、これを実行している間に、私はこのインポートされたもののようなエラーメッセージが表示されて解決できません。 1.6以上のAndroidバージョンがIMFをサポートすると私が知る限り、インストールする必要のあるEclipseプラグインはありますか?Androidカスタムキーボード実装

答えて

0

質問は非常に古くなっていますが、これを見る別のユーザーを助けるかもしれないので、私はそれに答えています。

問題を解決するためにEclipse用のプラグインがあるかどうか尋ねられましたが、今はAndroidスタジオがあります。

実装したい方Android Custom Keyboard: 最初にAndroidカスタムキーボード用のGoogleサンプルプロジェクトをダウンロードしてください。

1つのテーマ(カスタムレイアウト)、2)サブタイプ、3)絵文字の3つの重要な機能が必要です。

テーマ/レイアウト用:レイアウトファイルを作成します。サブタイプについて

@Override 
public View onCreateInputView() { 

    // Set custom theme to input view. 
    int themeLayout = sharedPreferences.getInt(THEME_KEY, R.layout.input_1); 
    mInputView = (LatinKeyboardView) getLayoutInflater().inflate(
      themeLayout, null); 
    mInputView.setOnKeyboardActionListener(this); 

    // Close popup keyboard when screen is touched, if it's showing 
    mInputView.setOnTouchListener(new View.OnTouchListener() { 
     @Override 
     public boolean onTouch(View view, MotionEvent motionEvent) { 
      if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { 
       mInputView.closing(); 
      } 
      return false; 
     } 
    }); 

    // Apply the selected keyboard to the input view. 
    setLatinKeyboard(getSelectedSubtype()); 

    return mInputView; 
} 

<com.domain.keyboard.android.LatinKeyboardView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/keyboard" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:background="@drawable/kb_bg_9" 
    android:keyBackground="@drawable/key_bg_fill_white" 
    android:keyPreviewLayout="@layout/key_preview_layout" 
    android:keyPreviewOffset="@dimen/keyPreviewOffset" 
    android:keyTextColor="@color/white" 
    android:popupLayout="@layout/keyboard_popup_layout" /> 

そしてSoftKeyboard.javaに次のコードを使用します。以下の例のコードを参照してくださいqwerty.xmlのコピーを作成し、キーを交換し、それを編集します。 LatinKeyboardの別のインスタンスをSoftKeyboard.javaに作成し、ifまたはswitchロジックを使用します。

private LatinKeyboard getSelectedSubtype() { 
    final InputMethodSubtype subtype = mInputMethodManager.getCurrentInputMethodSubtype(); 
    String s = subtype.getLocale(); 
    switch (s) { 
     case "ps_AF": 
      mActiveKeyboard = mPashtoKeyboard; 
      mCurKeyboard = mPashtoKeyboard; 
      break; 
     case "fa_AF": 
      mCurKeyboard = mFarsiKeyboard; 
      break; 
     default: 
      mCurKeyboard = mQwertyKeyboard; 
    } 

    return mCurKeyboard; 
} 

そして追加するmethods.xmlを編集サブタイプ:顔文字については

<input-method xmlns:android="http://schemas.android.com/apk/res/android" 
    android:settingsActivity="com.sunzala.afghankeyboard.android.ImePreferences" 
    android:supportsSwitchingToNextInputMethod="true"> 
    <subtype 
     android:imeSubtypeLocale="en_US" 
     android:imeSubtypeMode="keyboard" 
     android:label="@string/label_subtype_generic" /> 
    <subtype 
     android:imeSubtypeLocale="ps_AF" 
     android:imeSubtypeMode="keyboard" 
     android:label="@string/label_subtype_generic" /> 
    <subtype 
     android:imeSubtypeLocale="fa_AF" 
     android:imeSubtypeMode="keyboard" 
     android:label="@string/label_subtype_generic" /> 
</input-method> 

:ライブラリを検索し、キーボードでそれを統合します。顔文字はキーを押すと表示されます。

if (primaryCode == -10000) { 
    showEmoticons(); 
} 

ここで、-10000はkeycodeです。