我在下面的代码中有问题,这frmChinese.append(txtField);
对我不起作用。
将此文本字段与我的表单绑定的正确方法是什么?我使用的头文件和库也被提及。
package com.lbs;
import com.lbs.MidletSplashScreen;
import com.sun.lwuit.*;
import com.sun.lwuit.Button;
import com.sun.lwuit.Command;
import com.sun.lwuit.Form;
import com.sun.lwuit.Image;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.plaf.Border;
import java.io.IOException;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.TextField;
public class Chinese extends Form implements ActionListener {
Form frmChinese = null;
Command cmdExit = null;
TextField txtField = null;
Chinese() {
frmChinese = this;
frmChinese.setTitle("Chinese");
frmChinese.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
this.getStyle().setBgColor(0xFF5240);
ShowUi();
cmdExit = new Command("Exit");
Command cmdBack = new Command("Back"); // new command with name Back
frmChinese.addCommand(cmdExit);// add command in Form
frmChinese.addCommand(cmdBack);// add command in Form
frmChinese.setBackCommand(cmdBack); // setting back command
frmChinese.addCommandListener(this); // register action listener in form
}
private void ShowUi() {
txtField = new TextField("","Search", 20, TextField.ANY);
frmChinese.append(txtField);
}