Java Micro Editionを使用していて、レコードストアを使用して簡単なログインフォームを作成しようとしています。ユーザーが詳細を入力したら、保存されているものと照合して、ウェルカムエリアなどの別の画面に移動します。
フォーム要素とその切り替えに関係があると感じていますが、グーグルではどこにも行けないようです
これを試して
form = new Form("login");
form.addCommand(getExitCommand());
form.addCommand(getOkCommand());
form.setCommandListener(this);
public void commandAction(Command command, Displayable displayable) {
if (displayable == form) {
if (command == exitCommand) {
exitMIDlet();
} else if (command == okCommand) {
display.setCurrent(getWelcomeForm());
}
} else if (displayable == form1) {
if (command == backCommand) {
// do something else
}
}
}
displayは、コンストラクター内およびその上にも作成する必要があるものです。
public class YourMidlet extends MIDlet implements CommandListener {
private Display display;
private Form form1;
private Form form2;
public YourMidlet
{
display = Display.getDisplay(this);
form 1 = new Form("hello form this is form 1");
form 2 = new Form("hello form 2");
display.setCurrent(form1);
}
}
次に、次のことを行います。
display.setCurrent(form2);
フォーム2に切り替える