import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class TextBoxDemo extends MIDlet implements CommandListener
{
private Display display=Display.getDisplay(this);
private TextBox textBox;
private Command cmdOK=new Command("写好了",Command.SCREEN,1);
private Command cmdExit=new Command("不写了",Command.SCREEN,2);
private Alert alert;
public TextBoxDemo()
{
// TODO Auto-generated constructor stub
textBox=new TextBox("呆,输入电话号码","",11,TextField.PHONENUMBER);
textBox.addCommand(cmdOK);
textBox.addCommand(cmdExit);
textBox.setCommandListener(this);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException {
// TODO Auto-generated method stub
display.setCurrent(textBox);
}
public void commandAction(Command arg0, Displayable arg1)
{
// TODO Auto-generated method stub
if(arg0==cmdOK)
{
alert=new Alert("发送","",null,AlertType.INFO);
alert.setTimeout(3000);
alert.setString("正在发送……");
display.setCurrent(alert, display.getCurrent());//将该对话框设置为当前的屏幕
}
else if(arg0==cmdExit)
{
try {
destroyApp(false);
} catch (MIDletStateChangeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
notifyDestroyed();
}
}
}
文本框TextBox类的应用
原创
©著作权归作者所有:来自51CTO博客作者hackerain的原创作品,请联系作者获取转载授权,否则将追究法律责任
下一篇:Form表单的应用
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
jQuery学习笔记——文本框的应用
入框增加一个样式--> 单行文本的应用 .focus{ border: 1px solid #f00; background: #fcc; } $(function(){ $(":input").f
jquery addClass animated input fieldset