투케이2K

386. (android/java) AutoCompleteTextView 사용해 텍스트 자동 완성 (auto complete) 기능 설정 실시 본문

Android

386. (android/java) AutoCompleteTextView 사용해 텍스트 자동 완성 (auto complete) 기능 설정 실시

투케이2K 2022. 11. 4. 11:35
반응형

[개발 환경 설정]

개발 툴 : AndroidStudio

 

[Xml : 소스 코드]

            <AutoCompleteTextView
                android:id="@+id/auto_edit"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_marginLeft="30dp"
                android:layout_marginRight="30dp"
                android:layout_weight="0.5"
                android:background="#ffffff"
                android:gravity="center"
                android:hint="auto text"
                android:text=""
                android:textColor="#000000"
                android:textSize="12dp"
                android:textStyle="bold"
                android:layout_marginTop="10dp"/>
 

[Java : 소스 코드]

		// [컴포넌트 매핑 실시]
		AutoCompleteTextView auto_edit = (AutoCompleteTextView) findViewById(R.id.auto_edit);

		// [자동 완성 단어 설정 실시]
		String item[] = {"C","C++","Java",".NET","iPhone","Android","ASP.NET","PHP"};

		// [어댑터 설정]
		auto_edit.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, item));
 

[결과 출력]


 

반응형
Comments