简体   繁体   English

Android首选项列表文件

[英]Android Preferences List Files

I am trying to make a preferences option that will show the name of all of the files in a specific directory. 我正在尝试创建一个首选项选项,该选项将显示特定目录中所有文件的名称。 I have looked, but I haven't seen anything that can do this. 我看了,但我没有看到任何可以做到这一点。 Is there a way? 有办法吗? Thanks! 谢谢!

William 威廉

This 这个

File dir = new File(path_dir); 
File[] files = dir.listFiles();

will get you an array of all the files under path_dir directory. 将为您提供path_dir目录下所有文件的数组。 Iterate over it and and append files[i].getName() to an array of CharSequence. 迭代它并将files [i] .getName()附加到CharSequence数组。

CharSequence[] entries = ...;
ListPreference lp = new ListPreference(this);
lp.setEntries(entries);
lp.setEntryValues(entries);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM