안드로이드 이야기

안드로이드 - autocompletetextview 커스텀마이징

mapagilove 2012. 9. 1. 17:17
728x90
반응형

안드로이드 - autocompletetextview 커스텀마이징

Add this in your xml file

<AutoCompleteTextView  
android:id="@+id/name"
android:layout_width="300dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:textSize="20dp"
android:gravity="center"
android:layout_marginBottom="10dp"
android:textColorHint="#D20B2C"/>

In your Activity.java file

   AutoCompleteTextView drpText =   (AutoCompleteTextView) this.findViewById(R.id.name); 
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.auto_list_item, UserArr);
drpText
.setAdapter(adapter);
//UserArr===> is the array of names which you want to display in AutoCompleteTextView

xml for auto_list_item

<?xml version="1.0" encoding="utf-8"?> 
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp"
android:background="@android:color/transparent"
android:textColor="#000">
</TextView>
728x90
반응형