J'essaie de créer une vue pour un InputMethodService qui affiche une vue Keyboard ainsi que d'autres widgets. Dans ce code, j'essaie d'afficher un "Hello" TextView juste en dessous du clavier. Je ne vois aucune erreur ou avertissement dans l'onglet Conception de disposition du fichier ListKeyboard.xml, mais lorsque le clavier logiciel est chargé, je ne peux pas voir le texte.Combinaison d'autres widgets dans une vue InputMethodService
Le code provient de l'exemple de clavier logiciel SDK. Au lieu d'utiliser input.xml, je crée un fichier de mise en page relative dans listkeyboard.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/llwrapper"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true">
<com.example.android.softkeyboard.LatinKeyboardView
android:id="@+id/keyboard"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text = "@string/hello"
android:layout_centerHorizontal="true"
android:layout_below="@id/keyboard"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
Voici le code onCreateInputView:
@Override public View onCreateInputView() {
mListKeyboard = (RelativeLayout) getLayoutInflater().inflate(
R.layout.listkeyboard, null);
mInputView = (LatinKeyboardView)
mListKeyboard.findViewById(R.id.keyboard);
mInputView.setOnKeyboardActionListener(this);
setLatinKeyboard(mQwertyKeyboard);
return mInputView;
}