- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个用于从手机存储器浏览文件的类,它使用list附加文件列表,而我还有另一个类作为mainInterface。
所以我怎样才能将该列表类调用到mainInterface中呢?
这是文件浏览器类
public class FileBrowser implements CommandListener {
private String currDirName;
protected String fileName;
private Command open = new Command("Open", Command.ITEM, 1);
private Command back = new Command("Back", Command.BACK, 2);
private Command exit = new Command("Exit", Command.EXIT, 3);
private final static String UP_DIR = "...";
private final static String MEGA_ROOT = "/";
private final static String SEP_STR = "/";
private final static char SEP = '/';
public Display d;
public FileBrowser(){
currDirName = MEGA_ROOT;
fileName = null;
}
public String getFileName(){
return fileName;
}
public void startBrowsing(){
boolean isAPIAvailable = false;
if(System.getProperty("microedition.io.FileConnection.version") != null){
isAPIAvailable = true;
try{
showCurrDir();
}catch(SecurityException se){}
catch(Exception e){}
}
else{ }
}
public void showCurrDir(){
Enumeration e;
FileConnection currDir = null;
List browser;
try{
if(MEGA_ROOT.equals(currDirName)){
e = FileSystemRegistry.listRoots();
browser = new List(currDirName, List.IMPLICIT);
}
else{
currDir = (FileConnection)Connector.open("file://localhost/" + currDirName);
e = currDir.list();
browser = new List(currDirName, List.IMPLICIT);
browser.append(UP_DIR, null);
}
while(e.hasMoreElements()){
fileName = (String)e.nextElement();
if(fileName.charAt(fileName.length()-1) == SEP){
browser.append(fileName, null);
} else{
browser.append(fileName, null);
}
}
browser.setSelectCommand(open);
browser.addCommand(exit);
browser.setCommandListener(this);
if(currDir != null){
currDir.close();
}
} catch(IOException ioe){}
}
public void commandAction(Command c, Displayable d){
if(c == open){
List curr = (List)d;
final String currFile = curr.getString(curr.getSelectedIndex());
new Thread(new Runnable()
{
public void run()
{
if (currFile.endsWith(SEP_STR) ||
currFile.equals(UP_DIR)) {
traverseDirectory(currFile);
}
else {
openFile(currFile);
}
}
}).start();
}
else if (c == back)
{
showCurrDir();
}
}
public void traverseDirectory(String fileName){
if(currDirName.equals(MEGA_ROOT)){
if(fileName.equals(UP_DIR)){
return;
}
currDirName = fileName;
} else if(fileName.equals(UP_DIR)){
int i = currDirName.lastIndexOf(SEP, currDirName.length()-2);
if(i != -1){
currDirName = currDirName.substring(0, i+1);
}
else{
currDirName = MEGA_ROOT;
}
}
showCurrDir();
}
public void openFile(String fileName){
try{
FileConnection fc = (FileConnection) Connector.open("file://localhost/" + currDirName + fileName);
if(!fc.exists()){
throw new IOException("File does not exists");
}
InputStream fileIS = fc.openDataInputStream();
byte[] b = new byte[1024];
int length = fileIS.read(b, 0, 1024);
fileIS.close();
fc.close();
TextBox tb = new TextBox("View File: " + fileName, null, 1024, TextField.ANY | TextField.UNEDITABLE);
tb.addCommand(back);
tb.addCommand(exit);
tb.setCommandListener(this);
if (length > 0)
{
tb.setString(new String(b, 0, length));
}
} catch(Exception e){}
}
}
public void actionPerformed(ActionEvent ae){
if(ae.getSource() == open){
start the filebrowsing screen
}
}
最佳答案
您需要将其移植到LWUIT才能正常工作。 LWUITDemo的1.4版本在树部分中包含文件树演示。这也是LWUIT聊天演示的一部分。
关于audio - 如何显示J2me中其他类的列表(LCDUI)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5367659/
我有一个用于从手机存储器浏览文件的类,它使用list附加文件列表,而我还有另一个类作为mainInterface。 所以我怎样才能将该列表类调用到mainInterface中呢? 这是文件浏览器类 p
我想在我的 LWUIT 应用程序中使用标准警报对话框(如 LCDUI):lcdui Alert javadocs 如何从 LWUIT 表单调用此方法? 最佳答案 LWUIT 1.5 的 Display
我已经构建了一个包含 Midlet 的 LWUIT UI 类。我基本上使用的是这个 midlet 中的主题。但我需要跳转到另一个包含一些 LCDUI 控件的 LCDUI 表单,并且我需要设置显示该 L
我习惯使用lcdui界面,但我想使用lwuit界面。谁能告诉我不同的命令列表。 package newpackage; import java.io.IOException; import j
我正在尝试使用http://www.jappit.com/blog/2008/12/04/j2me-animated-gif-encoder/从jpeg文件创建gif这个线程是我的引用How to c
这个问题在之前的一些问题中已经间接谈到,但我还没有看到任何决定性的内容.. 我目前正在使用这段代码在 CommandAction 实现中显示 LWUIT 表单。 public void command
在 LWUIT 元素上绘制自定义元素(即使用 J2ME native 图形)的最佳方法是什么? 自定义元素是映射库的实现,它将其内容(例如 Google map )绘制到 Graphics 对象。如何
您好,我是一名 Android 开发人员,但我是 Symbian 开发新手。我找不到任何可以在表单上放置按钮的类。我如何在 Symbian 上执行此操作。不确定我做的是否正确。 最佳答案 使用Text
我刚刚开始使用 J2ME 和 lcdui,我正在查看一些从工作线程调用 lcdui 对象方法的示例代码。 根据我使用桌面 GUI 工具包的经验,这通常是被禁止的 - lcdui 有什么不同吗?这样做真
我使用的是 NetBeans 6.9.1。当我尝试 import javax.microedition.lcdui.Command; import javax.microedition.lcdui.C
我在使用 import javax.microedition.lcdui.* 时遇到错误; 包 javax.microedition.lcdui.* 不存在。 但是行 import javax.mic
如何向 javax.microedition.lcdui.CustomItem 添加监听器,以便在选择它时触发事件? 谢谢 最佳答案 没有听众。您要做的就是覆盖各种低级输入事件,例如pointerPr
我是一名优秀的程序员,十分优秀!