MIDlet中对图片等资源文件的存取

来源:互联网 发布:卡玛d1c知乎 编辑:程序博客网 时间:2024/05/11 11:13

通过测试发现,在MIDlet中可以用目录的方式对某类资源文件归类存放,运行的时候可以正常存取。程序示例如下

……

?String[] imgPath = {"/srcs/byf_banshenyinliao.png","/srcs/fxh_byf_heying.png",
????"/srcs/fxh_half_120.png","/srcs/fxh_jushou.png","/srcs/heying_five.png"};

……

??Image image = null;

??try {
???image = Image.createImage (imgPath[sel_num]);
??????????????? }
??????????????? catch (Exception ex) {
??????????????????? ex.printStackTrace ();
??????????????? }

??Displayable nd =new BigPicCanvas(image);

……

此例中所有的图片都存放在srcs目录下,打包suilt的时候把该目录一起打包就行了。生成的jar在模拟器下运行通过

原创粉丝点击