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년 전
Cursor Adapter#1 - Simple cursor adapter Cursor Adaptercursor adapter는 커서로 읽은 정보를 list로 만들어 주는 역할을 한다.따라서 DB에서 읽은 정보를 listview 형태로 보여줄때 사용한다. Simple Cursor Adaptercursor adatper중에 가장 간단한 adapter 이다.Simple cursor adatper는 cursor에 있는 정보를 textView나 imageView로 보여줄때 사용한다.생성자는 아래와 같이 만들 수 있다.- from: column의 배열- to: column과 mapping될 layout의 view id Example간단하게 contact의 정보를 받아 list로 보여주는 예제는 아래와 같다import android.provider.ContactsContract.Commo.. 개발이야기/Android 7년 전