SQLite 데이터베이스에서 효율적으로 ListView 내에서 AutoCompleteTextView를 채우는 방법은 무엇입니까?

StackOverflow https://stackoverflow.com/questions/9030278

문제

목록 뷰를 내 사용자 정의 DataAdaptor에서 채우고 있습니다.목록 뷰의 각 항목 / 행에 대해 레이아웃이 정의되어 있습니다.그 내부에서는 AutoCompleTextView가 있습니다.SQLite 데이터베이스의 데이터와 함께 묶어야합니다.실제로이 AutoCompleTeTextView는 카테고리를 나열 할 것이며 이러한 범주는 SQLite Table.I에서 가져올 것입니다. getView () 내부에서 사용자 지정 데이터 계층 클래스에서 바인딩 할 수 있지만 SQLite 데이터베이스에 대한 여러 호출을 피하는 방법을 모르겠습니다.

카테고리가 각 행에 대해 동일하게 유지되므로 얻고 싶습니다. 데이터베이스에서 한 번만 한 번 카테고리에 넣고 각 행의 AutoCompleteTextView.

누군가가 어떻게해야 하는지를 안내 할 수 있습니까?

감사합니다.

도움이 되었습니까?

해결책

To avoid multiple database calls ..

You can fetch data in cursor from database in your activity's onCreate() then using CursorAdapter or SimpleCursorAdapter bind it (using setAdapter) to AutoCOmpleteTextView in your list Adapter's getView()..

This example will help you lot Using AutocompleteTextView with SQLite and CursorAdapter

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top