1:IO读写
因为J2ME只支持有限的几个IO类,要用这几个类满足自己的需求确实不容易。
try
{
InputStream is = new Object().getClass().getResourceAsStream("/52.txt");
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
byte[] bytes=new byte[128];
int size;
while( (size = is.read(bytes)) != -1 ){
baos.write(bytes, 0, size);
}
data=baos.toByteArray();
iSize=data.length;
contentCan = new contentCanvas(new String(data));
is.close();
is = null;
baos.close();
baos = null;
}
catch (Exception e)
{
e.printStackTrace();
}
2:字符串转换成整数或其它primitive类型
image_1_num = Integer.parseInt(str3.substring(0,str3.indexOf("-")));
image_2_num = Integer.parseInt(str3.substring(str3.indexOf("-")+1));
用了无数次了,但每次还是忘记。
3:ChoiceGroup的一个小问题
看API文档
public ChoiceGroup(Stringlabel,
intchoiceType,
String[]stringElements,
Image[]imageElements)
Creates a new ChoiceGroup
, specifying its title, the type of the ChoiceGroup
, and an array of Strings
and Images
to be used as its initial contents.
The type must be one of EXCLUSIVE
, MULTIPLE
, or POPUP
. The IMPLICIT
type is not allowed for ChoiceGroup
.
The stringElements
array must be non-null and every array element must also be non-null. The length of the stringElements
array determines the number of elements in the ChoiceGroup
. The imageElements
array may be null
to indicate that the ChoiceGroup
elements have no images. If the imageElements
array is non-null, it must be the same length as the stringElements
array. Individual elements of the imageElements
array may be null
in order to indicate the absence of an image for the corresponding ChoiceGroup
element. Non-null elements of the imageElements
array may refer to mutable or immutable images.
有以下问题要澄清:
1:第二个参数类型只能为EXCLUSIVE, MULTIPLE
, or POPUP,IMPLICIT 不被支持,这点和List不同。
2:第三个参数不能为null。
3:第四个参数可以为null。
但是不知道为什么,在我的开发中,始终无法用POPUP类型,Eclipse老提示无法解析此类型。
分享到:
相关推荐
J2ME扫雷源代码J2ME扫雷源代码J2ME扫雷源代码J2ME扫雷源代码J2ME扫雷源代码J2ME扫雷源代码J2ME扫雷源代码J2ME扫雷源代码J2ME扫雷源代码J2ME扫雷源代码J2ME扫雷源代码J2ME扫雷源代码
J2ME麻将源代码J2ME麻将源代码J2ME麻将源代码J2ME麻将源代码J2ME麻将源代码
分享:J2ME游戏代码 分享:J2ME游戏代码 分享:J2ME游戏代码分享:J2ME游戏代码 分享:J2ME游戏代码 分享:J2ME游戏代码分享:J2ME游戏代码 分享:J2ME游戏代码 分享:J2ME游戏代码分享:J2ME游戏代码 分享:J2ME...
J2ME播放器源代码J2ME播放器源代码J2ME播放器源代码J2ME播放器源代码J2ME播放器源代码J2ME播放器源代码
多款J2ME游戏源代码 代码详细
j2me各种游戏代码,对初学者很有帮助,是初学者对精通手机开发垫下了很好的基础。。。。。
J2ME高手的代码宝库,囊括J2ME经典的算法函数,直接复制就可用。源码带详细注释
J2ME时钟代码J2ME时钟代码J2ME时钟代码
J2ME大量源代码,例子 整套例子,由浅入深,基本全部功能都有
J2me 游戏代码
郭克华J2me课件与代码!网上有配套视频教程!
经典j2me视频播放器代码经典j2me视频播放器代码.rar经典j2me视频播放器代码.rar经典j2me视频播放器代码.rar经典j2me视频播放器代码.rar
J2ME常用API(中文).CHM midp2.0的常用API
J2me赤血英豪源代码(6种机型)J2me赤血英豪源代码(6种机型)
自己整理的,一共两种方法。...在欢迎界面显示一个标题,一张图片,一个退出按钮,按退出按钮则退出程序,要自己先准备一张图片,建议不要太大,然后把图片放到项目下的res文件夹里,再把代码里的图片名换过来即可。
基于J2ME的游戏代码(含报告),绝对能跑
非常好的J2ME地图源代码2非常好的J2ME地图源代码2非常好的J2ME地图源代码2
J2ME 五子棋人机对站程序源代码 人工智能
郭克华 J2ME PPT 源代码郭克华 J2ME PPT 源代码郭克华 J2ME PPT 源代码郭克华 J2ME PPT 源代码郭克华 J2ME PPT 源代码郭克华 J2ME PPT 源代码郭克华 J2ME PPT 源代码郭克华 J2ME PPT 源代码
J2me 游戏代码