2017-05-31 66 views
0

我試圖爲顯示鍵盤視圖以及其他小部件的InputMethodService創建一個視圖。在這段代碼中,我試圖在鍵盤下方顯示一個「hello」TextView。我在ListKeyboard.xml文件的Layout Design選項卡中看不到任何錯誤或警告,但是當加載軟鍵盤時,我看不到文本。將其他小部件組合到一個InputMethodService視圖中

代碼來自SDK softkeyboard示例。我不使用input.xml,而是在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> 

這裏是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; 
} 

回答

0

我一直在這麼長的時間獨自返回鍵盤看法......我應該已經返回衆目睽睽之下,mListKeyboard,其中包括TextView的。

相關問題