Cursor Adapter#3 - Resource Cursor Adatper ResourceCursorAdatper는 원하는 layout.xml과 연결할 때 사용한다.앞에서 설명한 Cursor Adapter와의 다른점은 아래와 같다.1. Constructor의 매개 변수로 xml layout을 넣는다.2. newView()에서 inflate하지 않는다. (이미 inflate되어 bindView()로 넘어온다.) 아래 예제는 contcctBadge에 resourceCursorAdapter를 이용하여 cursor의 자료를 붙이는 예제이다.public class ContactsQuery extends ListActivity { static final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { Contacts._ID, // 0 Con.. 개발이야기/Android 7년 전
Cursor Adapter#2 - Custom Cursor Adapter SimpleCursorAdapter나 SimpleTreeCusorAdapter같은 경우 정해진 layout내의 view요소에 값을 할당 하는 방식으로 동작한다. 만약, DB에서 문자를 찾아 만드는 자동완성뷰나, 스피너를 만들기 위해서는 CursorAdapter를 상속받아 직접 구현해야 한다. 이는 Adpater를 만들기 위해 BaseAdatper를 상속받아 구현하는것과 비슷하다. Cursor Adatper의 상속CursorAdatper를 상속할때는 아래와 같은 세가지 작업을 수행한다.1. Constructor 생성2. bindView() 구현3. newView() 구현 예제) Text의 자동완성 기능을 Cursor Adapter를 이용하여 구현한다.import android.provider.Contact.. 개발이야기/Android 7년 전