简体   繁体   English

如何在j2me中使一些文本框彼此相邻

[英]how to make some textbox next to each other in j2me

i'm working on a j2me project with java wireless toolkit and i need to make 4 textbox next to each other. 我正在使用Java无线工具包进行j2me项目,我需要使4个文本框彼此相邻。 i used these for: 我将这些用于:

private TextField emailTxt;
private TextField passwordTxt;
private TextField nameTxt;
private TextField mobileTxt;
private TextField urlTxt; 

public UserRegistrationMIDlet() {
    emailTxt = new TextField("pelak:\n", "", 2, TextField.EMAILADDR);
    passwordTxt = new TextField("", "", 1, TextField.PASSWORD);
    nameTxt = new TextField("", "", 3, TextField.ANY);
    mobileTxt = new TextField("", "", 2, TextField.PHONENUMBER);
    urlTxt = new TextField("address:", "", 100, TextField.URL);

} }

but j2me textboxes and textfields, every one fill a line and become under each other. 但是j2me文本框和文本字段中的每一个都填充一行并互相覆盖。 as i searched for i understood the Textbox has no set location method but isn't there any other way to make them just next to each other? 当我搜索时,我知道文本框没有设置位置的方法,但是没有其他方法可以使它们彼此相邻吗? fn: some one said that it's possible with changing the margins?! fn:有人说改变边距有可能吗? how?! 怎么样?!

I'm assuming you are adding these TextField to a Form , so, according to documentation : 我假设您正在将这些TextField添加到Form ,所以根据文档

Layout policy in Form is organized around rows. Form中的布局策略是围绕行组织的。 Rows are typically related to the width of the screen, respective of margins, scroll bars, and such. 行通常与屏幕的宽度,页边距,滚动条等有关。 All rows in a particular Form will have the same width. 特定表单中的所有行将具有相同的宽度。 Rows do not vary in width based on the Items contained within the Form, although they may all change width in certain circumstances, such as when a scroll bar needs to be added or removed. 尽管行在某些情况下(例如,当需要添加或删除滚动条时)都可能改变宽度,但行的宽度不会根据表单中包含的项目而改变。 Forms generally do not scroll horizontally. 表单通常不会水平滚动。

But you play with setLayout . 但是您可以使用setLayout For example: 例如:

emailTxt.setLayout(Item.LAYOUT_2 | Item.LAYOUT_SHRINK);
passwordTxt.setLayout(Item.LAYOUT_2 | Item.LAYOUT_SHRINK);
nameTxt.setLayout(Item.LAYOUT_2 | Item.LAYOUT_SHRINK);
mobileTxt.setLayout(Item.LAYOUT_2 | Item.LAYOUT_SHRINK);
urlTxt.setLayout(Item.LAYOUT_2 | Item.LAYOUT_SHRINK);

As a last resort you can build your own input field extending from CustomItem and have all your fields merged into one. 作为最后的选择,您可以构建从CustomItem扩展的自己的输入字段,并将所有字段合并为一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM