如何删除列表视图文件浏览器中的条目和视频文件?
问题描述:我想要一个“删除”功能,它可以执行删除/删除列表视图中所选条目的操作,同时删除Video_List目录中驻留的视频文件字符串,然后刷新列表视图的内容?
我对 android/java 相当陌生,有人可以帮助我吗?请向下滚动以评估我面临的问题!有人可以告诉我我应该添加到当前代码中以执行上述功能的具体代码是什么吗?
Problem description: I wanted a "delete" function which could perform delete/remove of the selected entry in a listview and at the same time delete the residing video file string in the Video_List directory then it refresh the content of the listview?
I'm rather new in android/java can someone help me with it? Do scroll down to evaluate the problem i'm facing please!! Can someone tell me what is the specific code i should add into my current codes to perform the above mention function??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
由于您已将选择存储到“item”对象中,因此在 deleteFile() 方法中,您需要从该对象检索文件路径,为此,请添加以下行:
在 getVideoFiles() 方法“for”循环中。
也在 onCreate 状态之前:
然后在 getVideoFiles 的最终状态:
最后在 deleteFile() 中你需要声明:
那应该可行!
Since you have stored your selection into "item" object then in deleteFile() method you need to retreive the file path from that object, for that to work add the line:
in getVideoFiles() method 'for' loop.
also before onCreate state:
then in getVideoFiles at the end state:
finally in deleteFile() you need to state:
and that should work!
您定义了 onListItemClick 覆盖,但从未调用此代码。您还应该将侦听器注册到您正在使用的视图。检查 android 如何处理用户界面事件
You defined an override onListItemClick but this code is never been called. You should also register the a listener to the view you're using. Check how android handle user interface events.
您要删除适配器还是要删除列表中的行/条目?如果是后者,则更新 videoItems 并在适配器上调用 notificationDataSetChanged。如果您确实想删除适配器,只需将其设置为 NULL 或让它引用其他一些 ListAdapter 实例,GC 将处理其余的事情。
Do you want to delete the adapter or do you want to delete a row/entry in the list? If latter, then update videoItems and call notifyDataSetChanged on your adapter. If you really want to delete the adapter, then just set it to NULL or have it refer to some other ListAdapter instance and the GC will take care of the rest.