【发布时间】:2014-07-11 23:58:21
【问题描述】:
我的列表包含具有 name 和 status 的元素。名称是 String,status 是 int。
我想要一个ListView,其中每个元素都显示name 和一个用于选择status 的下拉菜单。此外,背景颜色将根据 status int 更改。
我有光标:
String[] ItemsData= { "id", "name", "status" };
Cursor ItemsCursor = ItemsDatabase.query(
Database.ITEMS_TABLE, ItemsData, null, null, null, null, null
);
ItemsCursor.moveToFirst();
我已经创建了列表(以编程方式我必须这样做):
ListView ItemsListView = new ListView(this);
现在,我知道我可以使用和Adapter(如SimpleCursorAdapter)但我不知道该怎么做,考虑到name 是String 内的TextView status 是一个Spinner,预定义的值在数据库中保存为int,默认值是与status 对应的值。此外,status 也会改变背景颜色。
也许我不能使用Adapter。另外,如果可能的话,我不知道如何在每个列表元素中包含 Spinner。
【问题讨论】:
-
您应该在 xaml 中为 ListView 创建项目。 This教程可以帮到你
-
我可以预料到让适配器为列表视图的每一行膨胀 DropDown 的复杂性。我宁愿建议一个对话框,该对话框包含下拉菜单,以便在点击单个列表元素时出现。
-
对,我将放置一个按钮,该按钮必须包含与每个状态编号对应的文本。但是,如何让
Cursor将数字转换为String,然后再将其绑定到ListView?
标签: android sqlite listview spinner android-adapter