안드로이드 개발 정보
(글 수 1,067)
원본 : http://c1dong8.blog.me/10099150322
동작에 대해선 전 글에서 설명했습니다만.....
자세한 건 원본 클릭 하시고
당연하지만 이거 그대로 쓸일 별로 없습니다.
커스텀을 해야지요 ㅎㅎ
p.s. 블로그 홍보냐?
ㅇㅇ
-_-;
동작에 대해선 전 글에서 설명했습니다만.....
자세한 건 원본 클릭 하시고
package ViewControl; import android.content.Context; import android.text.Editable; import android.text.TextWatcher; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.TextSwitcher; /** * claAutoCompleteTextView * * @author DangGun Roleeyas ( http://c1dong8.blog.me ) * @version 1.0 ( 2010.11.28 ) * * 오토 컴플리트 텍스트 뷰 * * 이 클래스는 그대로 사용하지 말고 복사해서 사용해야 합니다. * 이 클래스는 뷰들의 세팅작업을 한번에 완료하고 제어하는데 목적이 있습니다. * * 클래스 자체적으로 뷰객체를 저장하고 있으므로 외부에서는 이 클래스의 객체만 생성해서 사용하세요. * GetOvject() 메소드를 통해 저장되있는 객체에 직접 접근 할수 있습니다. * * 복사한후 자신이 사용하려는 동작을 할수 있게 직접 수정하셔야 합니다. * 이 클래스의 내용은 참고용으로 사용 하시기 바랍니다. * * 자동완성텍스트뷰를 제어하기 위한 리스너 클래스입니다. * 데이터 제어는 여기서 하지 않고 데이터를 제어하기위한 인터페이스만 제공합니다. * * 만약 오토 컴플리트 텍스트 뷰가 여러개이면 이 클래스도 여러개 생성해야 합니다.(일반 리스너와 동일, ) * */ public class claAutoCompleteTextView extends TextSwitcher { ArrayAdapter<String> strACAdapter; AutoCompleteTextView acView; /** * 생성자 * * 오토 컴플리트 텍스트 뷰에 아답터를 연결한후 제어할 리스너를 연결합니다. * 연결할 데이터를 미리 설정해놓는 방식은 데이터를 정적일때 사용합니다.연결할 데이터 * * 연결할 데이터가 동적이라면 데이터를 갱신해주는 클래스를 받아서 afterTextChanged()를 호출할때마다 갱신되게 해야 합니다. * * @param context 메인 뷰 * @param acView 이 클래스 내에 객체가 저장되므로 객체를 따로 저장 하실 필요는 없습니다. * @param items[] 연결할 데이터 */ public claAutoCompleteTextView(Context context, AutoCompleteTextView acView, String items[]) { super(context); this.acView = acView; //아답터 생성 strACAdapter = new ArrayAdapter<String>( context, android.R.layout.simple_dropdown_item_1line, items); //아답터 연결 this.acView.setAdapter(strACAdapter); //리스너 등록 this.acView.addTextChangedListener( twTextChanged); } //텍스트가 변경되었을때 사용할 리스너 생성 private TextWatcher twTextChanged = new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }; /** * @return 이 클래스가 소유하고 있는 객체를 리턴합니다. */ public AutoCompleteTextView GetOvject() { return this.acView; } }
당연하지만 이거 그대로 쓸일 별로 없습니다.
커스텀을 해야지요 ㅎㅎ
p.s. 블로그 홍보냐?
ㅇㅇ
-_-;