我正在填充我的自定义数据Adaptor的ListView。我为列表视图的每个项目/行定义了一个布局。在该ListView中,我有一个autocompleteText视图。我需要将其与来自SQLite数据库的数据绑定。实际上,这个autocompletetextview将列出类别和这些类别将来自一个sqlite table.i可以将它绑定在getview()中的自定义DataDapeter类中,但我不知道如何避免对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