在j2me中加载画面

问题描述 投票:0回答:1

我想在我的应用程序中,当互联网连接开始时,它就会出现,而当我从webservice获取数据时,加载屏幕就会被隐藏。

我曾尝试使用.gif文件。在我制作的简单应用程序中,它可以正常工作,只显示.gif文件。但是当我把这段代码与我的应用程序j集成时,它显示出错误。

该错误是。

TRACE: <at java.lang.IllegalArgumentException>, Exception caught in Display class
java.lang.IllegalArgumentException
        at javax.microedition.media.Manager.createPlayer(), bci=8
        at com.semaphore.GifCanvas.<init>(GifCanvas.java:41)
        at com.semaphore.CompanySplashScreen.dismiss(CompanySplashScreen.java:89)
        at com.semaphore.CompanySplashScreen.keyPressed(CompanySplashScreen.java:78)
        at javax.microedition.lcdui.CanvasLFImpl.uCallKeyPressed(), bci=19
        at javax.microedition.lcdui.DisplayableLFImpl.uCallKeyEvent(), bci=146
        at javax.microedition.lcdui.Display$DisplayEventConsumerImpl.handleKeyEvent(), bci=30
        at com.sun.midp.lcdui.DisplayEventListener.process(), bci=277
        at com.sun.midp.events.EventQueue.run(), bci=179
        at java.lang.Thread.run(Thread.java:619)

我使用的执行.gif文件的代码是:-。

InputStream ins = getClass().getResourceAsStream("/loading.gif");
        try {
            player = Manager.createPlayer(ins, "image/gif");
             player.prefetch();
             player.setLoopCount(10);

        player.start();
        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (MediaException ex) {
            ex.printStackTrace();
        }
        if ((vidc = (VideoControl) player.getControl("VideoControl")) != null)
        vidc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
        try {
            vidc.setDisplayLocation(2, 2);
            vidc.setDisplaySize(getWidth()/2,getHeight()/2);
        }
        catch (MediaException me) {}
        vidc.setVisible(true);

我如何解决这个问题?

java-me
1个回答
0
投票

根据 文件,你的InputStream是空的。检查你的资源是否放置正确。 有了这个路径,它应该在你的项目的根目录下(或者src目录,我不确定)。但只是检查一下。

© www.soinside.com 2019 - 2024. All rights reserved.