我正在android中开发一个应用程序。我使用的是存储访问框架,可以选择多个文件,但不能选择文件夹。是否无法选择文件夹?
我们尝试了什么1
可以选择多个文件,但不能选择文件夹。
class MainFragment : Fragment() {
private val launcher =
registerForActivityResult(ActivityResultContracts.GetMultipleContents()){ result ->
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.materialButton.setOnClickListener {
launcher.launch(null)
}
}
}
我们尝试了什么2
多项选择和文件选择不可用。
class MainFragment : Fragment() {
private val launcher =
registerForActivityResult(ActivityResultContracts.OpenDocumentTree()){ result ->
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.materialButton.setOnClickListener {
launcher.launch(null)
}
}
}
我使用的是存储访问框架,我可以选择多个文件,但不能选择文件夹。
我假设你的意思是说:
我使用的是存储访问框架,我可以选择多个文件,但不能选择多个文件夹。
(强调显示添加的上下文(
如果是,那么是的,就没有多个树("文件夹"(选项,就像有多个文档选项一样。期望用户在感兴趣的树之间选择一些共同的父级。从那里,你的应用程序可以呈现自己的UI,允许用户使用所选树的特定子树。