파일명 : activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/autoCompleteTextView1"
android:completionHint="선택하세요"
android:completionThreshold="2"
android:hint="자동완성텍스트뷰"
/>
<MultiAutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/multiAutoCompleteTextView1"
android:completionHint="선택하세요"
android:completionThreshold="2"
android:hint="멀티자동완성텍스트뷰"
/>
</LinearLayout>
파일명 : MainActivity.java
package com.example.it.myapplication6_10;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.MultiAutoCompleteTextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String[] items = {"CSI-뉴욕", "CSI-라스베가스", "CSI-마이애미", "Friends",
"Fringe", "Lost"};
AutoCompleteTextView auto = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, items);
auto.setAdapter(adapter);
MultiAutoCompleteTextView multi = (MultiAutoCompleteTextView) findViewById(R.id.multiAutoCompleteTextView1);
MultiAutoCompleteTextView.CommaTokenizer token = new MultiAutoCompleteTextView.CommaTokenizer();
multi.setTokenizer(token);
multi.setAdapter(adapter);
}
}
'IT > Android' 카테고리의 다른 글
android - ViewFlipper (0) | 2018.09.17 |
---|---|
android - ProgressBar, SeekBar, RatingBar, ScrollView, SlidingDrawer (0) | 2018.09.16 |
android - FrameLayout , Chronometer, TimePicker, CalendarView (0) | 2018.09.10 |
android - TableLayout과 GridLayout으로 만든 버튼형 계산기 (0) | 2018.09.09 |
android - LinearLayout, RelativeLayout, TableLayout (0) | 2018.09.08 |