Hi I implemented a SearchView which shows results in a ListView.The problem I am facing is that I have a custom keyboard and my Listview is overlapping over the keyboardView so I am not able to press some of the keys on my keyboard.What I want to achieve is my Listview to be displayed under the KeyboardView.Here is my layout file
<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>
Also I want to hide the custom keyboard when the user browses through the ListView and code for changing the visibility of keyboard
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;
}
}
});
Another thing I want to do is change the background for my keyboard keys.I was not able to do this I tried adding android:keyIcon attribute to each of the keys but it did not work and only the preview background image changes when I use this attribute.How do I go about doing this.
<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>
And this is how I instantiate the 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);
Can someone please guide me where I am going wrong or suggest how I should proceed.Thanks for the help.
To view your keyboard above your listview, Change your layout to,
<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" >
<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>
<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" />
</RelativeLayout>