I am trying to create AutoCompleteTextView in my android app. The problem is that I cannot configure it
Works well with the following code:
AutoCompleteTextView autoTextView = (AutoCompleteTextView) findViewById(R.id.fillText);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, typeAutoFill);
autoTextView.setAdapter(adapter);
//typeAutoFill is my String array that stores the values which must appear.
But the size of the suggested texts is too big for my application. I need to make them smaller. I have looked at similar questions posted here.
I tried:
android:dropDownHeight="" //with different values
This does not make any changes.
I also tried using ArrayAdapter with an XML resource file containing only a TextView with properties of my choice:
AutoCompleteTextView autoTextView = (AutoCompleteTextView) findViewById(R.id.fillText);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.auto_fill_item,R.id.autoFillTextView,typeAutoFill);
autoTextView.setAdapter(adapter);
And this is causing my application to crash.
This is actually a problem. I've tried different options. Can anyone please help? Thanks in advance.
+3
source to share
2 answers
try this, make your own design for the text textdesign.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textAutoComplete"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#f45455"
android:gravity="center_vertical"
android:padding="5dp" />
Your autocomplete
AutoCompleteTextView etChoose= (AutoCompleteTextView) findViewById(R.id.autocomplete);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout. textdesign, ChooseList);
autoTextView.setAdapter(adapter);
+2
source to share