J2me手机ui里的textbox代码有一句看不懂,帮忙看看
packagetextbox;importjavax.microedition.lcdui.*;importjavax.microedition.midlet.MIDle...
package textbox;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
public class TextBoxDemo extends MIDlet implements CommandListener {
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);
static final String[] textBoxLabels =
{ "Any Character", "E-Mail", "Number", "Decimal", "Phone", "Url" };
static final int[] textBoxTypes =
{
TextField.ANY, TextField.EMAILADDR, TextField.NUMERIC, TextField.DECIMAL,
TextField.PHONENUMBER, TextField.URL
};
private Display display;
private ChoiceGroup types;
private ChoiceGroup options;
private Form mainForm;
private boolean firstTime;
public TextBoxDemo() {
display = Display.getDisplay(this);
firstTime = true;
}
protected void startApp() {
if (firstTime) {
mainForm = new Form("Select a Text Box Type");
mainForm.append("Select a text box type");
Image[] imageArray = null;
types = new ChoiceGroup("Choose type", Choice.EXCLUSIVE, textBoxLabels, imageArray);
mainForm.append(types);
// advanced options
String[] optionStrings = { "As Password", "Show Ticker" };
options = new ChoiceGroup("Options", Choice.MULTIPLE, optionStrings, null);
mainForm.append(options);
mainForm.addCommand(CMD_SHOW);
mainForm.addCommand(CMD_EXIT);
mainForm.setCommandListener(this);
firstTime = false;
}
display.setCurrent(mainForm);
}
protected void destroyApp(boolean unconditional) {
}
protected void pauseApp() {
}
public void commandAction(Command c, Displayable d) {
if (c == CMD_EXIT) {
destroyApp(false);
notifyDestroyed();
} else if (c == CMD_SHOW) {
Image[] imageArray = null;
int index = types.getSelectedIndex();
String title = textBoxLabels[index];
int choiceType = textBoxTypes[index];
boolean[] flags = new boolean[2];
options.getSelectedFlags(flags);
if (flags[0]) {
choiceType |= TextField.PASSWORD;//功能是实现choiceType以**形式表示,请问是怎么实现的?
}
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);
}
}
}
我用中文注释了的啊....在后面一点
if (flags[0]) {
choiceType |= TextField.PASSWORD;//功能是实现choiceType以**形式表示,请问是怎么实现的?
} 展开
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
public class TextBoxDemo extends MIDlet implements CommandListener {
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);
static final String[] textBoxLabels =
{ "Any Character", "E-Mail", "Number", "Decimal", "Phone", "Url" };
static final int[] textBoxTypes =
{
TextField.ANY, TextField.EMAILADDR, TextField.NUMERIC, TextField.DECIMAL,
TextField.PHONENUMBER, TextField.URL
};
private Display display;
private ChoiceGroup types;
private ChoiceGroup options;
private Form mainForm;
private boolean firstTime;
public TextBoxDemo() {
display = Display.getDisplay(this);
firstTime = true;
}
protected void startApp() {
if (firstTime) {
mainForm = new Form("Select a Text Box Type");
mainForm.append("Select a text box type");
Image[] imageArray = null;
types = new ChoiceGroup("Choose type", Choice.EXCLUSIVE, textBoxLabels, imageArray);
mainForm.append(types);
// advanced options
String[] optionStrings = { "As Password", "Show Ticker" };
options = new ChoiceGroup("Options", Choice.MULTIPLE, optionStrings, null);
mainForm.append(options);
mainForm.addCommand(CMD_SHOW);
mainForm.addCommand(CMD_EXIT);
mainForm.setCommandListener(this);
firstTime = false;
}
display.setCurrent(mainForm);
}
protected void destroyApp(boolean unconditional) {
}
protected void pauseApp() {
}
public void commandAction(Command c, Displayable d) {
if (c == CMD_EXIT) {
destroyApp(false);
notifyDestroyed();
} else if (c == CMD_SHOW) {
Image[] imageArray = null;
int index = types.getSelectedIndex();
String title = textBoxLabels[index];
int choiceType = textBoxTypes[index];
boolean[] flags = new boolean[2];
options.getSelectedFlags(flags);
if (flags[0]) {
choiceType |= TextField.PASSWORD;//功能是实现choiceType以**形式表示,请问是怎么实现的?
}
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);
}
}
}
我用中文注释了的啊....在后面一点
if (flags[0]) {
choiceType |= TextField.PASSWORD;//功能是实现choiceType以**形式表示,请问是怎么实现的?
} 展开
4个回答
ZESTRON
2024-09-04 广告
2024-09-04 广告
在Dr. O.K. Wack Chemie GmbH,我们高度重视ZESTRON的表界面分析技术。该技术通过深入研究材料表面与界面的性质,为提升产品质量与可靠性提供了有力支持。ZESTRON的表界面分析不仅涵盖了相变化、化学反应、吸附与解吸...
点击进入详情页
本回答由ZESTRON提供
2009-07-10
展开全部
choiceType = TextField.PASSWORD;
TextBox textBox = new TextBox(title, "", 50, choiceType);
TextBox构造方法的四个参数依次是文本框的标题,内容,字符长度和类型。 TextField.PASSWORD是密码类型,所以显示出来就是******了
TextBox textBox = new TextBox(title, "", 50, choiceType);
TextBox构造方法的四个参数依次是文本框的标题,内容,字符长度和类型。 TextField.PASSWORD是密码类型,所以显示出来就是******了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
可以使用TextField的 PASSWORD方法设置显示*
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你说哪句看不懂?要指出来。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询