学习型 ASP/PHP/ASP.NET 主机 30元/年全能 ASP/PHP/ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付
发新话题
打印

[求助]NOKIA的ItemStateListener事件

[求助]NOKIA的ItemStateListener事件

我写了个简单的程序,为什么装到Nokia3230机上运行出问题?
程序要求点击下拉框中的值时,将相应的值显示在文本框中.
问题是:无论选择下拉框中的哪个值,文本框中都没有反应.根本没有执行ItemStateChanged方法
哪位大侠可以解决?多谢了!

程序如下:

public class ItemStateDemo extends MIDlet implements CommandListener,ItemStateListener
{
private Form main=null;
private Display mydis=null;
private ChoiceGroup cgInfo=null;
private TextField txtInfo=null;
private Command cmdExit=null;

public void startApp()
{
main=new Form("Demo");
cgInfo=new ChoiceGroup("select:",ChoiceGroup.POPUP);
cgInfo.append("",null);
cgInfo.append("A",null);
cgInfo.append("B",null);
txtInfo=new TextField("","",10,TextField.ANY);
cmdExit=new Command("Exit",Command.EXIT,1);
main.append(cgInfo);
main.append(txtInfo);
main.addCommand(cmdExit);
main.setCommandListener(this);
main.setItemStateListener(this);
mydis=Display.getDisplay(this);
mydis.setCurrent(main);
}
public void pauseApp()
{
}
public void destroyApp(boolean u)
{
}
public void commandAction(Command c,Displayable d)
{
if(c==cmdExit)
{
destroyApp(true);
notifyDestroyed();
}
}
public void ItemStateChanged(Item item)
{
if(item==cgInfo)
{
this.txtInfo.setString(this.cgInfo.getString(this.cgInfo.getSelectedIndex());
}
}
}

TOP

为什么没人回答?版主大哥,提个意见吧,每次我有问题上咱们论坛都没有人回答,不是这么巧吧?我问的问题都很偏吗?
public class 人生历程 extends Thread{public void run(){while(true){努力,努力,再努力!!;Thread.sleep(0);}}}

TOP

以下是引用marer在2007-2-15 22:34:23的发言:
我写了个简单的程序,为什么装到Nokia3230机上运行出问题?
程序要求点击下拉框中的值时,将相应的值显示在文本框中.
问题是:无论选择下拉框中的哪个值,文本框中都没有反应.根本没有执行ItemStateChanged方法
哪位大侠可以解决?多谢了!

程序如下:

public class ItemStateDemo extends MIDlet implements CommandListener,ItemStateListener
{
private Form main=null;
private Display mydis=null;
private ChoiceGroup cgInfo=null;
private TextField txtInfo=null;
private Command cmdExit=null;

public void startApp()
{
main=new Form("Demo");
cgInfo=new ChoiceGroup("select:",ChoiceGroup.POPUP);
cgInfo.append("",null);
cgInfo.append("A",null);
cgInfo.append("B",null);
txtInfo=new TextField("","",10,TextField.ANY);
cmdExit=new Command("Exit",Command.EXIT,1);
main.append(cgInfo);
main.append(txtInfo);
main.addCommand(cmdExit);
main.setCommandListener(this);
main.setItemStateListener(this);
mydis=Display.getDisplay(this);
mydis.setCurrent(main);
}
public void pauseApp()
{
}
public void destroyApp(boolean u)
{
}
public void commandAction(Command c,Displayable d)
{
if(c==cmdExit)
{
destroyApp(true);
notifyDestroyed();
}
}
public void ItemStateChanged(Item item)//这里的i应该是小写,JAVA里面的方法名,第一个字母一般都是小写
{
if(item==cgInfo)
{
this.txtInfo.setString(this.cgInfo.getString(this.cgInfo.getSelectedIndex()));//这里小了一个括号
}
}
}

你的程序有两个错误,以现在的程序来看,是连编译都通过不了的

如果你把以前两点改过来以后就可以了,我这里运行没问题

Java,My Love!

TOP

上面的代码是我用手打上去的,实际的代码应该没有错,否则编辑不过去,但程序编辑过去了,但是就是没反应,肯定不是代码的错误.

public class 人生历程 extends Thread{public void run(){while(true){努力,努力,再努力!!;Thread.sleep(0);}}}

TOP

那就怪了,在我这里运行很正常啊

可惜不是你,陪我到最后

TOP

我的也有相同问题,就是不知道怎么无法执行?

TOP

发新话题