Для тех, кто пытается перетащить из ListView, есть хорошая новость: существует решение. Чтобы решить эту проблему, я использовал методы, связанные с on_selection_change
адаптера ListView, on_touch_down
ListView и on_touch_up
Scatter, которые я использовал для перетаскивания, как в следующем кодовый блок.
self.listview.bind(on_touch_down=self.press)
self.scatter.bind(on_touch_up=self.release)
self.adapter.bind(on_selection_change=self.selectionChange)
def selectionChange(self, adapter):
if adapter.selection: #Sometimes the selection was [], so a check doesn't hurt
names = adapter.data
self.scatter.children[0].text = adapter.selection[0].text #My scatter has a label as it's first and only child. Here, I'm changing the label's text
for j in adapter.data:
if j == adapter.selection[0].text:
break
names.pop(names.index(j))
self.listview.adapter.data = names
if(hasattr(self.listview, '_reset_spopulate')): #This is used to reset the ListView
self.listview._reset_spopulate()
def press(self, view, touch):
if view.collide_point(touch.x, touch.y) and not touch.is_mouse_scrolling:
self.scatter.center = touch.pos
self.floatLayout.add_widget(self.scatter) #The scatter appears on the click
self.scatter.on_touch_down(touch) #Needs to be called to get the scatter to be dragged
def release(self, scatter, touch):
if scatter.collide_point(touch.x, touch.y) and touch.grab_current: #Because Kivy's on_touch_up doesn't work like I think it does
#Do whatever you want on the release of the scatter
self.floatLayout.remove_widget(self.scatter) #Remove the scatter on release
Возможно, я неправильно прочитал ваш вопрос, но вы написали:
// filePath - строка, содержащая путь к файлу, например http://test.com/file.zip [ 111]
blockquote>Поэтому вы хотите удалить файл (каталог) на веб-сервере, а не на локальном компьютере или в локальной сети? В этом случае вам необходимо выполнить некоторые FTP-команды (например, Apache FTP-клиент )
. Лучше всего начать с Apache Commons.net и использовать только те части, которые вам нужны (например, FTP / FTPS).
import org.apache.commons.net.ftp.FTPClient; [..] FTPClient ftpClient = new FTPClient(); ftpClient.connect(server, port); ftpClient.login(user, pass); ftpClient.deleteFile(fileToDelete); ftpClient.logout(); ftpClient.disconnect();