ButtongroupとResourceertion
-
26-10-2019 - |
質問
Lwuit Resource Editorを可能な限り使用してアプリケーションを作成しようとしています。可能であれば、コードごとにUIの作成を避けようとしています。
グループをに割り当てる可能性があることがわかりました RadioButton
リソースエディターツールに対応するプロパティを設定します。
したがって、これらのラジオボタンに何らかの機能を実装する必要があるため、どうすればそのボタンループインスタンスへの参照を取得できますか UIBuilder
作成しましたか(私は思います)?
そして、はい、リソースエディターツールを使用してミッドレットを生成していることを考慮すると、「カスタム」コードが書かれています。 StateMachine
クラス。
よろしく。
解決
あなたが得ることができないafaik ButtonGroup
から Resourcedit#GUI. 。あなたは得ることができるだけです RadioButton
グループ名。しかし、追加することは可能です RadioButton
の中へ ButtonGroup
あなたのコードを通して。次のコードを参照してください、
呼び出しのために StateMachine()
コンストラクター(コンストラクター内のこのコードを使用)、
Form form = (Form) this.startApp(resources, null, true);
RadioButton rb1 = this.findRadioButton(form);
RadioButton rb = this.findRadioButton1(form);
ButtonGroup bg = new ButtonGroup();
bg.add(rb);
bg.add(rb1);
bg.setSelected(0);
呼び出しのために StateMachine(String resFile)
コンストラクター(ミッドレットクラス内のこのコードを使用してください)、
StateMachine sm = new StateMachine("/Sample.res");
RadioButton rb1 = sm.findRadioButton(Display.getInstance().getCurrent());
RadioButton rb = sm.findRadioButton1(Display.getInstance().getCurrent());
ButtonGroup bg = new ButtonGroup();
bg.add(rb);
bg.add(rb1);
bg.setSelected(0);
所属していません StackOverflow