Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AutocompleteTextView suggestion list goes up

Tags:

possible duplicates Android : autocompletetextview, suggestion list displays above the textview?

I am fully trying to display suggestion list overlapping on keyboard when suggestion list scroll by user but it always open up side.

here I am getting this way

enter image description here

here is my manifest file

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.sl"     android:versionCode="1"     android:versionName="1.0" >      <uses-sdk android:minSdkVersion="8" />      <application         android:icon="@drawable/ic_launcher"         android:label="@string/app_name" >         <activity             android:label="@string/app_name"             android:name=".SuggestionListActivity"              android:windowSoftInputMode="adjustResize|adjustPan|stateHidden">             <intent-filter >                 <action android:name="android.intent.action.MAIN" />                  <category android:name="android.intent.category.LAUNCHER" />             </intent-filter>         </activity>     </application> </manifest> 

here is my main.xml file

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical" android:padding="10dp">      <TextView         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:text="@string/hello"          android:layout_margin="10dp"/>      <TextView android:layout_margin="10dp"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:text="This is testing for the auto complete textview in this application to display suggestion list overlapping on keyboard." />      <AutoCompleteTextView android:id="@+id/autocomplete"             android:layout_width="fill_parent" android:layout_margin="5dp"             android:layout_height="wrap_content" android:hint="Search"             android:layout_marginLeft="5dp" android:dropDownHeight="300dp"             android:inputType="textAutoComplete" android:singleLine="true"             />  </LinearLayout> 

what to do in this code to display the suggestion over keyboard when list was focus.

like image 990
Pratik Avatar asked Jul 19 '12 05:07

Pratik


2 Answers

I've had this problem before. For me, there was more screen space above the AutocompleteTextView than below (testing on a "normal" device), so the list opened upwards. I adjusted my layout slightly so that there was more space below the AutocompleteTextView and it started opening downwards. That's what fixed it for me.

like image 122
Mike T Avatar answered Oct 13 '22 00:10

Mike T


You can either adjust the layout so that there is more space below the AutoCompleteTextView

or

you can change the dropdown height android:dropDownHeight and set some high value, this would work when its inside a scrollView and the AutoCompleteTextView is near the top.

To display the list of options on focus do something like this

autoCompleteTextView.setOnFocusChangeListener(new OnFocusChangeListener() {     public void onFocusChange(View v, boolean hasFocus) {         if(hasFocus) {             autoCompleteTextView.showDropDown();         }     } }); 

This would display a list of options when the user focuses on the AutoCompleteTextView

like image 33
Gautam Avatar answered Oct 13 '22 00:10

Gautam