首页 > 解决方案 > Kivy FileChooser 在某些 android 手机上不能作为 apk 工作,我该如何解决?

问题描述

当我尝试实现 kivy 的文件选择器时,我发现它在没有 Xaomi 手机的情况下在任何地方都运行良好。当我转到该页面时,它显示文件选择器的空布局。我的代码如下:

Mypopup:
pos: (root.width * .025, root.height *.020)
#size:(300,300)
auto_dismiss: True
size_hint:(1,1)
id:pop
BoxLayout:
    orientation:'vertical'
    FileChooserIconView:
        id: filechooser
        on_selection: pop.selected(filechooser.selection)
    Button:
        text:'upload'
        size_hint_x:.7
        size_hint_y:.1
        background_color:1,1,1,1
        on_release:pop.dismiss
        pos_hint:{'center_x':.5,'center_y':.5}
        on_press: app.next_screen('resource/tima/know_myself/my_information')

标签: androidpython-3.xkivyfilechooser

解决方案


尝试路径/storage/emulated/0/

例如,将其添加到您的.kv文件中,如下所示:

#:import platform kivy.utils.platform

FileChooserListView:
    rootpath: '/storage/emulated/0/' if platform == 'android' else '/'

推荐阅读