//main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<AutoCompleteTextView
android:id="@+id/edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:completionHint="pick a item"
android:completionThreshold="2"
/>
</LinearLayout>android:completionThreshold="2"
: 사용자가 입력한 글자가 몇 글자일 때 문자열 리스트를 보여줄지를 지정하는 속성이다.
//AutoCompleteTextViewActivity.java
import android.app.*;
import android.os.*;
import android.widget.*;
public class AutoCompleteTextViewActivity extends Activity {
String[] items = {"SM3","SM5","SM7","SONATA","AVANTE","SOUL","K5","K7"};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AutoCompleteTextView edit = (AutoCompleteTextView)findViewById(R.id.edit);
edit.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, items)
);
}
}//main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<MultiAutoCompleteTextView
android:id="@+id/edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:completionHint="pick a item"
android:completionThreshold="2"
/>
</LinearLayout>import android.app.*;
import android.os.*;
import android.widget.*;
public class AutoCompleteTextViewActivity extends Activity {
String[] items = {"SM3","SM5","SM7","SONATA","AVANTE","SOUL","K5","K7"};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/*
AutoCompleteTextView edit = (AutoCompleteTextView)findViewById(R.id.edit);
edit.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, items)
);
*/
MultiAutoCompleteTextView edit = (MultiAutoCompleteTextView)findViewById(R.id.edit);
edit.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
edit.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, items)
);
}
}
[Android] 스타일 과 테마 (0) | 2011.07.31 |
---|---|
[Android]자바 코드에서 직접 뷰를 추가하는 방법 (0) | 2011.07.31 |
[Android] 뷰 (0) | 2011.07.26 |
[Android] 컴포넌트 활성화 및 비활성화 (0) | 2011.07.26 |
[Android] 인텐트와 인텐트 필터 살펴보기 (0) | 2011.07.26 |
댓글 영역