2016-08-30 20 views
1

XMLを使用する代わりに、Javaコードでカスタムキーボードの行とキーをプログラム的に作成する必要があるアプリケーションで作業しています。 これは可能ですか?はいの場合は、どうすればいいのですか?実行時に行とキーをアンドロイドでカスタムキーボードに追加する

現在、私はXMLを使用して、このように行を作成しています: -

<Keyboard android:keyWidth="10.0%p" 
android:keyHeight="@dimen/key_height" android:horizontalGap="0.0px"android:verticalGap="0.0px" 
xmlns:android="http://schemas.android.com/apk/res/android"> 

<Row android:rowEdgeFlags="top" > 
    <Key android:codes="-21" android:keyIcon="@drawable/arbiclinenew" /> 
    <Key android:codes="-51" android:keyIcon="@drawable/recentlinenew" /> 

</Row> 

基本的に、私はのように、ユーザがすべての最近選択された絵文字が同じ表示し、私のキーボードで"recent"ビューを表示する必要がありますどのように? お願いします.. !!!!

答えて

1

最後に、独自のカスタムキーボードを作成することができます。最近のボタンを表示するカスタムキーボードレイアウトを作成することができます。たとえば:目に見えないし、独自のレイアウトを表示することができます。

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent"> 


    <android.inputmethodservice.KeyboardView 
     android:id="@+id/keyboard" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:textDirection="rtl" 
     android:keyPreviewLayout ="@layout/preview"></android.inputmethodservice.KeyboardView> 

<android.support.v4.view.ViewPager 
     android:id="@+id/view_pager" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
    /> 


</FrameLayout> 

、任意のキークリック時に、あなたは絵文字や他のビューを表示する必要があり、その後、私たちは、キーボードの可視性を設定することができたとします。

関連する問題