J2ME基本问题之变量Item
做了一个程序,如果文本域中有内容就显示出:“清除”按钮。但是有两个文本域,我用Item变量来判断是哪个文本域
private Item item=null;
public void commandAction(Command c,Displayable d){
if(c==cmdClear){
if(item==tf_ch){
System.out.print("检验输出");
int position1=tf_ch.getCaretPosition();
tf_ch.delete(position1-1, 1);
log.removeCommand(cmdClear);
log.addCommand(cmdExit);
}
}
只是一小段代码,不全。有些我没写出来,我想问的就这里面的item用的对不对啊,怎么连“检验输出”四个字都没显示出来啊,我的程序到底哪里错了
PS:如果只是一个文本域的时候,不用item判断,我的程序就完全正确