【发布时间】:2011-11-01 15:37:16
【问题描述】:
我正在尝试在列表中显示blackberry 设备中可用的所有图像。如何使用 java api 扫描和获取黑莓中的所有图像名称?
【问题讨论】:
-
这是一个非常广泛的问题。你自己尝试过什么?
标签: image listview blackberry java-me
我正在尝试在列表中显示blackberry 设备中可用的所有图像。如何使用 java api 扫描和获取黑莓中的所有图像名称?
【问题讨论】:
标签: image listview blackberry java-me
使用以下类来定位设备中的所有图像。一开始,你调用函数时没有给字符串任何值:checkImages("");
public void checkImages(String imagePath) {
String path = "";
if (imagePath.equals(""))
path = "file:///SDCard/";
else
path = imagePath;
try {
FileConnection fileConnection = (FileConnection)Connector.open(path);
if (fileConnection.isDirectory()) {
Enumeration directoryEnumerator = fileConnection.list("*", true);
Vector contentVector = new Vector();
while(directoryEnumerator.hasMoreElements()) {
contentVector.addElement(directoryEnumerator.nextElement());
}
fileConnection.close();
for (int i = 0 ; i < contentVector.size() ; i ++) {
String name = (String) contentVector.elementAt(i);
checkImages(path + name);
}
}
else {
if (path.toLowerCase().endsWith(".jpg")) {
imm.addElement(path); // your Vector
fileConnection.close();
}
}
} catch (Exception ex) { }
}
【讨论】:
FileConnection 实例。