问题
I have a problem, when pressing on the list of the recyclerview i print the number of the index but i need print the value in the index code in below please any one can help me
class SecondWindow(BoxLayout,Screen):
myresult = ListProperty([("N_matricule", "Operateur")])
def insert_part(self):
partnum = self.ids.Part_field
part = partnum.text
mycursor.execute(
"""SELECT OPERATION_DESCRIPTION FROM liste_des_operations WHERE PART_NO = %s""",
(part,))
self.myresult = mycursor.fetchall()
#for row in myresult:
#print(row)
#print(type(row))
class RVItem(Factory.Button):
def get_data_index(self, values):
return self.parent.get_view_index_at(self.center)
def on_press(self):
print(self.get_data_index())
kv file
RecycleView:
data: [{'text':"{}".format(OPERATION_DESCRIPTION)} for OPERATION_DESCRIPTION in root.myresult]
viewclass: "RVItem"
RecycleBoxLayout:
default_size: None, dp(56)
orientation: "vertical"
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
key_selection: 'selectable'
multiselect: True
touch_multiselect: True
来源:https://stackoverflow.com/questions/61563477/print-the-value-selected-in-recycleview-kivy