我試圖創建一個Android鍵盤,現在我希望它只是膨脹,即顯示,從main.xml中如何膨脹LinearLayout(用於Android鍵盤)?
這裏的LinearLayout是java文件
package keyboard.rob.com;
import ...
public class zyz extends InputMethodService
implements KeyboardView.OnKeyboardActionListener {
private KeyboardView mInputView;
@Override public void onCreate() {
super.onCreate();
}
@Override public View onCreateInputView() {
mInputView = (KeyboardView) getLayoutInflater().inflate(R.layout.main, null);
return mInputView;
}
}
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_gravity="center" android:id="@+id/LL_whole" android:orientation="vertical" android:clickable="false">
<LinearLayout android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:background="@layout/backrep" android:layout_gravity="center" android:id="@+id/LL_total" android:orientation="vertical" android:layout_height="wrap_content">
<LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:background="@drawable/spell_frame" android:layout_marginBottom="10px" android:layout_marginTop="5px" android:layout_gravity="center" android:id="@+id/LL_spell" android:paddingLeft="10px">
</LinearLayout>
<LinearLayout android:layout_height="wrap_content" android:orientation="horizontal" android:layout_gravity="center" android:layout_width="wrap_content" android:id="@+id/LLrow1">
</LinearLayout>
<LinearLayout android:layout_height="wrap_content" android:layout_gravity="center" android:orientation="horizontal" android:layout_width="wrap_content" android:id="@+id/LLrow2"></LinearLayout>
<LinearLayout android:layout_height="wrap_content" android:layout_gravity="center" android:orientation="horizontal" android:layout_width="wrap_content" android:id="@+id/LLrow3"></LinearLayout>
<LinearLayout android:layout_height="wrap_content" android:layout_gravity="center" android:orientation="horizontal" android:layout_width="wrap_content" android:id="@+id/LLrow4">
</LinearLayout>
</LinearLayout>
</LinearLayout>
和錯誤它崩潰了:
08-29 20:21:28.128: ERROR/AndroidRuntime(10227): java.lang.ClassCastException: android.widget.LinearLayout
任何想法?謝謝!
似乎工作,謝謝! – Roger
@NiranjPatel我們可以使用自定義鍵盤中的LIstview/Recyclview ..Plz help..Plz爲我提供了一些鏈接/資源..謝謝 –