本文整理汇总了Java中javax.microedition.lcdui.TextField类的典型用法代码示例。如果您正苦于以下问题:Java TextField类的具体用法?Java TextField怎么用?Java TextField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextField类属于javax.microedition.lcdui包,在下文中一共展示了TextField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setConstraints
import javax.microedition.lcdui.TextField; //导入依赖的package包/类
public void setConstraints(final int constraints) {
activity.post(new Runnable() {
public void run() {
if ((constraints & TextField.CONSTRAINT_MASK) == TextField.URL) {
editView.setSingleLine(true);
} else if ((constraints & TextField.CONSTRAINT_MASK) == TextField.NUMERIC) {
editView.setSingleLine(true);
editView.setInputType(InputType.TYPE_CLASS_NUMBER);
} else if ((constraints & TextField.CONSTRAINT_MASK) == TextField.DECIMAL) {
editView.setSingleLine(true);
editView.setInputType(
InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL);
} else if ((constraints & TextField.CONSTRAINT_MASK) == TextField.PHONENUMBER) {
editView.setSingleLine(true);
editView.setInputType(InputType.TYPE_CLASS_PHONE);
}
if ((constraints & TextField.PASSWORD) != 0) {
editView.setTransformationMethod(PasswordTransformationMethod.getInstance());
editView.setTypeface(Typeface.MONOSPACE);
}
}
});
}
示例2: createView
import javax.microedition.lcdui.TextField; //导入依赖的package包/类
public void createView() {
//#if javarosa.usepolishlocalisation
//setHint(Locale.get("hint.TypeOrScan"));
//#else
setHint("Type in your answer");
//#endif
//#style textBox
tf = new TextField("", "", 200, TextField.ANY);
if(qDef.instanceNode.required)
tf.setLabel("*"+((QuestionDef)qDef.element).getLongText()); //visual symbol for required
else
tf.setLabel(((QuestionDef)qDef.element).getLongText());
this.append(tf);
this.addNavigationButtons();
if (((QuestionDef)qDef.element).getHelpText()!=null){
setHint(((QuestionDef)qDef.element).getHelpText());
}
}
示例3: SendGui
import javax.microedition.lcdui.TextField; //导入依赖的package包/类
/**
*
* Constructor
*/
public SendGui(){
super("Write a message");
// Creating the Commands
sendTextPackage = new Command("Send",Command.ITEM,1);
displayLog = new Command("View log",Command.ITEM,4);
exit = new Command("Exit", Command.EXIT,0);
search = new Command("Search", Command.OK, 1);
input = new TextField("Message","",200,TextField.ANY);
// The ChoiceGroup containing the connected Nodes
connectedNodes = new ChoiceGroup("Choose recipients", Choice.MULTIPLE);
// Adding the elements
addCommand(sendTextPackage);
addCommand(displayLog);
addCommand(exit);
addCommand (search) ;
append(connectedNodes);
append(input);
}
示例4: isValidString
import javax.microedition.lcdui.TextField; //导入依赖的package包/类
/**
* Check is this is a valid string given the constraints
*
* @param dca string to check
* @param constraints the constraints
* @return true if this is a valid string
*/
public static boolean isValidString(DynamicCharacterArray dca,
int constraints) {
if (dca.length() == 0) {
return true;
}
switch (constraints & TextField.CONSTRAINT_MASK) {
case TextField.ANY: return true;
case TextField.DECIMAL: return checkDecimal(dca.toString());
case TextField.EMAILADDR: return true;
case TextField.NUMERIC: return checkNumeric(dca.toString());
case TextField.PHONENUMBER: return checkPhoneNumber(dca.toString());
case TextField.URL: return true;
}
return false;
}
示例5: handleGuiAction
import javax.microedition.lcdui.TextField; //导入依赖的package包/类
protected void handleGuiAction(GuiButton guiButton) {
if (!guiButton.enabled) {
return;
}
if (guiButton.getId() == 0) {
selectWorld(selectedWorld);
} else if (guiButton.getId() == 1) {
cc.displayGuiScreen(new GuiNewWorld(this, parentScreen));
guiButton.setEnabled(getElementsList().size() < maxWorlds);
} else if (guiButton.getId() == 2) {
cc.displayGuiScreen(new GuiYesNo(this, cc.langBundle.getText("GuiSelectWorld.deleteWorld.confirmationText")));
} else if (guiButton.getId() == 3) {
backToParentScreen();
} else if (guiButton.getId() == 4) {
cc.displayGuiScreen(new GuiTextBox(this, selectedWorld.getWorldName(), TextField.ANY, 64));
}
}
示例6: RecordStoreForm
import javax.microedition.lcdui.TextField; //导入依赖的package包/类
public RecordStoreForm() {
super("RecordStore");
addCommand(loadCommand);
addCommand(storeCommand);
addCommand(deleteCommand);
addCommand(listCommand);
textFiled = new TextField("Enter data", "", 128, TextField.ANY);
append(textFiled);
stringItem = new StringItem("Loaded data", "n/a");
append(stringItem);
messageItem = new StringItem("Info:", "Use menu to load and store data");
append(messageItem);
}
示例7: HTTPPanel
import javax.microedition.lcdui.TextField; //导入依赖的package包/类
public HTTPPanel() {
super("HTTP Connection");
String host = SimpleDemoMIDlet.instance.getAppProperty("microemu.accessible.host");
if (host == null) {
demoLocation = "http://www.microemu.org/test/";
} else {
demoLocation = "http://" + host + "/test/";
}
append(url = new TextField("URL:", demoLocation, 128, TextField.URL));
append(message = new StringItem("Message:", null));
append(status = new StringItem("Status:", null));
addCommand(goCommand);
}
示例8: EditBox
import javax.microedition.lcdui.TextField; //导入依赖的package包/类
public EditBox(VirtualList parentList, String caption, String text, TextInput ti, int boxType) {
this.ti = ti;
this.caption = caption;
this.parentList = parentList;
t = new ExTextBox(parentList, text, caption, false);
t.textbox.setConstraints(boxType);
t.textbox.addCommand(cmdOk);
if (ti.id != null) {
loadRecentList();
if (recentList.size() > 0) {
t.textbox.addCommand(cmdRecent);
}
}
t.textbox.addCommand(cmdCancel);
if (Config.getInstance().capsState) {
t.textbox.setConstraints(TextField.INITIAL_CAPS_SENTENCE);
}
t.show(this);
}
示例9: setInputMethodListener
import javax.microedition.lcdui.TextField; //导入依赖的package包/类
public void setInputMethodListener(InputMethodListener l)
{
inputMethodListener = l;
switch (l.getConstraints() & TextField.CONSTRAINT_MASK) {
case TextField.ANY :
case TextField.EMAILADDR :
case TextField.URL :
setInputMode(INPUT_ABC_LOWER);
break;
case TextField.NUMERIC :
case TextField.PHONENUMBER :
case TextField.DECIMAL :
setInputMode(INPUT_123);
break;
}
}
示例10: setConstraints
import javax.microedition.lcdui.TextField; //导入依赖的package包/类
public void setConstraints(final int constraints) {
activity.post(new Runnable() {
public void run() {
if ((constraints & TextField.CONSTRAINT_MASK) == TextField.URL) {
editView.setSingleLine(true);
} else if ((constraints & TextField.CONSTRAINT_MASK) == TextField.NUMERIC) {
editView.setSingleLine(true);
editView.setInputType(InputType.TYPE_CLASS_NUMBER);
} else if ((constraints & TextField.CONSTRAINT_MASK) == TextField.DECIMAL) {
editView.setSingleLine(true);
editView.setInputType(
InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL);
} else if ((constraints & TextField.CONSTRAINT_MASK) == TextField.PHONENUMBER) {
editView.setSingleLine(true);
editView.setInputType(InputType.TYPE_CLASS_PHONE);
}
if ((constraints & TextField.PASSWORD) != 0) {
editView.setTransformationMethod(PasswordTransformationMethod.getInstance());
editView.setTypeface(Typeface.MONOSPACE);
}
if ((constraints & TextField.INITIAL_CAPS_SENTENCE) != 0) {
editView.setRawInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
}
}
});
}
示例11: SubmitForm
import javax.microedition.lcdui.TextField; //导入依赖的package包/类
/**
* Constructor ErrorPrompt.
*
* @param parent ...
*/
public SubmitForm(MIDlet parent, LSClient client, ErrorPrompt errorPrompt) {
this.errorPrompt = errorPrompt;
this.client = client;
messageListener = new SentListener();
close = new Command("Back", Command.STOP, 2);
send = new Command("Send", Command.OK, 1);
sendForm = new Form("RoundTrip Form");
text = new TextField("Write message","",100,TextField.ANY);
sendForm.append(text);
field = new ChoiceGroup("Select Item",Choice.EXCLUSIVE,new String[]{"1","2","3","4","5"},null);
sendForm.append(field);
sendForm.addCommand(close);
sendForm.addCommand(send);
sendForm.setCommandListener(this);
midlet = parent;
reset();
}
示例12: setupFields
import javax.microedition.lcdui.TextField; //导入依赖的package包/类
private void setupFields() {
titleField = new TextField("Title", "", 32, TextField.ANY);
contentField = new TextField("Content", "", 128, TextField.ANY);
dateField = new DateField("Date", DateField.DATE);
categoryField = new ChoiceGroup("Category", Choice.EXCLUSIVE, Category.elements, null);
priorityField = new Gauge("Priority", true, 10, 5);
this.append(titleField);
this.append(contentField);
this.append(dateField);
this.append(categoryField);
this.append(priorityField);
}
示例13: initTextFied
import javax.microedition.lcdui.TextField; //导入依赖的package包/类
private TextField initTextFied(String title) {
final String tfTitle = (title == null) ? "Enter text:" : title;
TextField tf = new TextField(tfTitle, "", 8192, TextField.ANY);
tf.addCommand(CMDTEXT_OK);
tf.setDefaultCommand(CMDTEXT_OK);
tf.setItemCommandListener(this);
return tf;
}
示例14: read
import javax.microedition.lcdui.TextField; //导入依赖的package包/类
public String read(String title) {
if (title != null) {
println(title);
}
TextField tf = initTextFied(title);
form.append(tf);
synchronized (this) {
try {
wait();
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
return tf.getString();
}
示例15: createLoggingTextBox
import javax.microedition.lcdui.TextField; //导入依赖的package包/类
private TextBox createLoggingTextBox() {
TextBox box = new TextBox(Localization.get("message.log"), null, 1000,
TextField.UNEDITABLE);
box.addCommand(FormTransportCommands.CMD_BACK);
return box;
}