开发者

how to make a textfield numeric by default in lwuit?

i tried to make a application which takes the numeric value default. i have done coding like this

public void startApp(){
Display.init(this);
TextField amt=new TextField();
Form form=new Form(Test);
form.addComponent(amt);
amt.setConstraint(TextField.NUMERIC);
form.show(); 

}

When i setConstraint to numeric. it 开发者_运维百科only accepts numeric value but i need to press the hash key and chage the key entry style to numeric. so how can i make the text field which should only be able to take numeric input by default. thanks in adavance.


Use setInputModeOrder(...);. See the following sample code,

TextField txtf = new TextField();
txtf.setConstraint(TextField.NUMERIC);
txtf.setInputModeOrder(new String[] {"123"});
form.addComponent(txtf);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜