当前位置: 代码迷 >> J2ME >> 低级界面如何在list里实现既有图片和文字说明
  详细解决方案

低级界面如何在list里实现既有图片和文字说明

热度:7291   发布时间:2013-02-25 21:37:23.0
低级界面怎么在list里实现既有图片和文字说明?
rt
用画布做界面,需要在list里面增加一个图片和文字说明,它们需要在同一行?


------解决方案--------------------------------------------------------
drawImage
drawString
------解决方案--------------------------------------------------------
jmobilecore是什么?不知道,汗颜!
------解决方案--------------------------------------------------------

偶自己写的程序片段 基本能实现Canvas下的list制作绘图 选定框部分还在修改中 LZ可以自己完善下 LZ最好用继承GameCanvas,这样分层做效果好点
public void paint(Graphics g){
for(int i=0;i <=s.length-1;i++){
//img1是图片 s是String数组
g.drawImage(img1,50,img1.getHeight()+i*(img1.getHeight()+5)+50,Graphics.TOP|Graphics.LEFT);
g.drawString(s[i],img1.getWidth()+10+50,img1.getHeight()+i*img1.getHeight()+50,Graphics.TOP|Graphics.LEFT);
}
g.setColor(0x0000ff);
System.out.println(x);
g.drawRect(35,img1.getHeight()+50+x,img1.getWidth()+40,img1.getHeight());
if(change==1||change==2){
//在当前选定的项上添加矩形框 并覆盖掉别的矩形框
paintSelsct(g);
}
}

public void paintSelsct(Graphics g2){
g2.setColor(0xffffff);
if(change==1){
g2.drawRect(35,img1.getHeight()+50+img1.getHeight(),img1.getWidth()+40,img1.getHeight());
}else if(change==2){
g2.drawRect(35,img1.getHeight()+50-img1.getHeight(),img1.getWidth()+40,img1.getHeight());
}
}

public void keyPressed(int keycode){
int key=this.getGameAction(keycode);
System.out.println( "key "+key);
if(key==this.DOWN){
System.out.println( "向下 ");
change=2;
x+=img1.getHeight();
//通过改变g.drawRect(35,img1.getHeight()+50+x,img1.getWidth()+40,img1.getHeight());中x的值改变所选定的项
repaint();
}else if(key==this.UP){
System.out.println( "向上 ");
change=1;
x-=img1.getHeight();
//通过改变g.drawRect(35,img1.getHeight()+50+x,img1.getWidth()+40,img1.getHeight());中x的值改变所选定的项
repaint();
}
}
------解决方案--------------------------------------------------------
不停的学习中
------解决方案--------------------------------------------------------
无解.
问题详细点
  相关解决方案