|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
其实产生见解的过程就是训练自己发现问题,分析问题的能力。根据以上的认识我想谈下传统的学习与通过视频独立学习的优缺点:
当我们必要再挪动设备上输出数据时,TextBox就派上用处了,我们利用的TextBox机关函数参数共有四个,TextBoxtextbox=newTextBox(stringtitle,stringcontent,stringmaxLength,stringlimitType),第一个是题目,第二个是TextBox的初始内容,第三个是同意输出字符的最年夜长度,第四个是限定内型。值得注重的是:一个TextBox必需附加一个命令,不然用户将不克不及引发任何举动,而堕入这个TextBox中。
上面是一个罕见的TextBox的例子。
view plainprint?
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.thinkrace.TextBox;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import javax.microedition.lcdui.Ticker;
import javax.microedition.midlet.*;
/**
* @author pengjw
*/
public class TextBoxDemo extends MIDlet implements CommandListener{
private Display display;
private ChoiceGroup types;
private ChoiceGroup options;
private Form mainForm;
private static final Command CMD_EXIT = new Command("Exit", Command.EXIT, 1);
private static final Command CMD_BACK = new Command("Back", Command.BACK, 1);
private static final Command CMD_SHOW = new Command("Show", Command.SCREEN ,1);
private static final String[] textBoxLabels ={
"Any Character", "Email", "Number", "Decimal", "Phone", "URL"
};
private static final int[] textBoxTypes ={
TextField.ANY, TextField.EMAILADDR, TextField.NUMERIC,
TextField.DECIMAL, TextField.PHONENUMBER, TextField.URL
};
//firstTime用来判别TextBoxDemo是不是被实例化
private boolean firstTime;
public TextBoxDemo(){
/**
* 来自文档的申明
* Display represents the manager of the display and input devices of the system.
* It includes methods for retrieving properties of the device and for requesting that objects be displayed on the device.
* There is exactly one instance of Display per MIDlet and the application can get
* a reference to that instance by calling the getDisplay() method.
*/
display = Display.getDisplay(this);
firstTime = true;
}
public void startApp() {
if(firstTime){
mainForm = new Form("Select a Text Box Type");
mainForm.append("select a textbox type");
types = new ChoiceGroup("Choice Type", Choice.EXCLUSIVE, textBoxLabels, null);
mainForm.append(types);
String[] optionStrings = {"As Password", "Show Ticker"};
options = new ChoiceGroup("Options", Choice.MULTIPLE, optionStrings, null);
mainForm.append(options);
mainForm.addCommand(CMD_EXIT);
mainForm.addCommand(CMD_SHOW);
mainForm.setCommandListener(this);
firstTime = false;
}
//设置以后显现的窗体
display.setCurrent(mainForm);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
/**
* 完成CommandListener接口的笼统办法
* 依据分歧的Command做分歧的事变
*/
public void commandAction(Command c, Displayable d) {
if(c == CMD_EXIT){
destroyApp(false);
notifyDestroyed();
}
else if(c == CMD_SHOW){
int Index = types.getSelectedIndex();
String title = textBoxLabels[Index];
int choiceType = textBoxTypes[Index];
boolean[] flags = new boolean[2];
/**
* 来自文档的申明,这个办法能够给一个bool数组赋值
* Query the state of a choicegroup and renturns the state of all elements in the boolean array.
*/
options.getSelectedFlags(flags);
if(flags[0]){
choiceType = TextField.PASSWORD;
}
TextBox textBox = new TextBox(title,"",50,choiceType);
if(flags[1]){
textBox.setTicker(new Ticker("TextBox:" + title));
}
textBox.addCommand(CMD_BACK);
textBox.setCommandListener(this);
display.setCurrent(textBox);
}
else if(c == CMD_BACK){
display.setCurrent(mainForm);
}
}
}
<p>
从一个编程语言的普及程度来将,一个好的IDE是至关中要的,而现在的java的IDE虽然已经很好了,但是和.net网页编程比起来还是稍微差一些的,这是个客观事实。java要想普及的更好。DE是必须加以改进的。 |
|