我正在为Android编写一个简单的应用程序.
我有2个表 - 一个叫做'grous',另一个叫'group_items'.
我想使用可扩展列表来显示两个表中的数据.
最好的方法是什么?是否可以使用SimpleCursorTreeAdapter映射数据?我找不到任何有用的例子.
我看到使用ArrayAdapter创建可扩展列表的示例,所以我应该首先将数据转换为数组,然后使用它创建可扩展列表,还是可以直接执行此操作?
我不需要一个完整的工作示例 - 只是建议什么是正确和最有效的方法.
Leonti
我的数据库中有两个表 - 房间和设备.每个房间都有许多设备.我想制作一个可扩展的列表视图,其中房间名称为组,设备名称和状态为子项(打开或关闭).
任何人都可以给我一个简单的想法,因为我是Android的新手,所有教程都很难
这是我的数据库:
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table if not exists rooms (
id_room integer primary key autoincrement, "
+ "name_room text not null"
+ ");");
db.execSQL("create table if not exists devices (
id_device integer primary key autoincrement, "
+ "name_device text not null,"
+ "state_device text not null,"
+ "id_room references rooms"
+ ");");
}
Run Code Online (Sandbox Code Playgroud)