gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 11:16:25 25 4
gpt4 key购买 nike

我正在使用 java wireless toolkit 开发一个 j2me 项目,我需要制作 4 个彼此相邻的文本框。我用这些来:

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);

}

但是 j2me 文本框和文本字段,每个文本框和文本字段都填充一行并彼此位于下面。当我搜索时,我了解文本框没有设置位置方法,但是没有其他方法可以使它们彼此相邻吗?f.n:有人说改变边距是可能的?!怎么办?!

最佳答案

我假设您将这些 TextField 添加到 Form 中,因此,根据 documentation :

Layout policy in Form is organized around rows. 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.

但是你玩setLayout 。例如:

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);

作为最后的手段,您可以构建自己的输入字段,从 CustomItem 开始扩展。并将所有字段合并为一个。

关于java - 如何在j2me中使一些文本框彼此相邻,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31776189/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com