我想在python 3.3中使用kivy爲listview創建一個自定義listview項目。如何在kivy中創建自定義列表視圖項目?
listitem應該包含一個標籤和3個按鈕。
我創建了設置爲自定義項目類適配器CLS一個ListView如下:
ListView:
id: cue_list
adapter: ListAdapter(data=[], cls=ListItemButton)
item_strings: []
然後我設置類的規則是這樣的:
<ListItemButton>:
size_hint_y: root.size_hint_y
height: root.height
orientation:"horizontal"
Button:
size_hint: 0.2, 1.0
text: "delete"
然後在我的Python文件創建一個函數添加一些項目:
def addcue(self):
self.lv.adapter.data.extend(["new item"])
self.lv._trigger_reset_populate()
但奇怪的是,結果是這樣的: http://i.stack.imgur.com/dNmz1.png
如何在kivy中使用.kv文件語言從頭開始指定listview項目?