开发者

how to make a textfield numeric by default in lwuit?

开发者 https://www.devze.com 2023-03-20 23:49 出处:网络
i tried to make a application which takes the numeric value default. i have done coding like this public void startApp(){

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

精彩评论

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

关注公众号