您好我实现了一个SearchView,它显示了一个ListView中的结果。我面临的问题是我有一个自定义的键盘和我的列表视图重叠在keyboardView,所以我不能够按一些我要实现我的keyboard.What的钥匙是我的ListView中KeyboardView.Here下显示是我的布局文件在键盘视图顶部的Android列表视图
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/basic_bg" >
<android.inputmethodservice.KeyboardView
android:id="@+id/keyboardView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:visibility="gone" />
<SearchView
android:id="@+id/searchView"
android:layout_width="400dp"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_alignRight="@+id/textView3"
android:layout_marginLeft="49dp"
android:layout_marginTop="25dp"
android:layout_toRightOf="@+id/imageViewUp"
android:background="@drawable/delete_bg_5line"
android:ems="10"
android:hint="Destination Input Text"
android:textColor="#87CEFA" >
</SearchView>
<ListView
android:id="@+id/main_list_View"
android:layout_width="450dp"
android:layout_height="235dp"
android:layout_alignLeft="@+id/searchView"
android:layout_below="@+id/searchView"
android:listSelector="@android:color/transparent"
android:scrollbars="none" >
</ListView>
</RelativeLayout>
另外我想,当用户浏览ListView控件隐藏定制键盘 和改变键盘可见度的代码
searchtextView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method st4ub
toggleKeyboardVisibility(searchtextView);
}
private void toggleKeyboardVisibility(
AutoCompleteTextView searchViewWidget) {
KeyboardView keyboardView = (KeyboardView) findViewById(R.id.keyboardView);
int visibility = keyboardView.getVisibility();
switch (visibility) {
case View.VISIBLE:
keyboardView.setVisibility(View.GONE);
break;
case View.GONE:
case View.INVISIBLE:
keyboardView.setVisibility(View.VISIBLE);
searchtextView = searchViewWidget;
break;
}
}
});
另一件事我想要做的就是更改背景为我的键盘上的按键。我没能做到这一点,我尝试添加机器人:keyIcon属性,每个键的,但它没有工作,只有当我使用此属性时,预览背景图像会发生变化。我该如何去做这件事。
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:horizontalGap="0px"
android:keyBackground="@drawable/custom_keyboard_press_onekey"
android:keyWidth="10%p"
android:verticalGap="0px" >
<Row>
<Key
android:codes="1"
android:iconPreview="@drawable/custom_keyboard_press_onekey"
android:isRepeatable="true"
android:keyEdgeFlags="left"
android:keyIcon="@drawable/custom_keyboard_press_onekey"
android:keyLabel="1" />
</Row>
</Keyboard>
这就是我如何实例化键盘
final KeyboardView keyboardView = (KeyboardView) findViewById(R.id.keyboardView);
Keyboard keyboard = new Keyboard(this, R.layout.keyboard);
keyboardView.setKeyboard(keyboard);
keyboardView.setEnabled(true);
keyboardView.setPreviewEnabled(true);
keyboardView.setOnKeyboardActionListener(this);
有人可以请指导我在哪里,我错了或建议,应该怎样的帮助proceed.Thanks。
嘿如果我创建以上述方式我得到以下错误“指定的孩子已经有一个父的布局。你必须调用首先将子对象的父视图的removeView()移除“。你知道吗? – Anu