2
私はボタンを中心にしたいbbアプリケーションを開発しています。私はカスタムフィールドマネージャーを使用していません。以下 は、私のコードの一部です:ブラックベリーアプリケーションの画面の中心にボタンを合わせる
ButtonField button;
button=new ButtonField("Go!");
add(button);
私は画面の中央に配置するには、このボタンを好きになるでしょう。助けが必要。おかげ
私はここに...ポール...それが機能しなかったことにしようとしたがmainscreenのための私のコードです:
class Vfmdemo extends UiApplication {
// main method
public static void main(String[] args) {
Vfmdemo theApp = new Vfmdemo();
UiApplication.getUiApplication().pushScreen(new VFMScreen());
theApp.enterEventDispatcher();
}
}
// VFM
class VFMScreen extends MainScreen {
public VFMScreen(){
// create a manager and allow scrolling when lots of fields are added
VerticalFieldManager vfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL);
// add a label
vfm.add(new LabelField("VerticalFieldManager..."));
// add another label
vfm.add(new LabelField("default horizontal alignment is left"));
// add another label that takes up full screen width
vfm.add(new LabelField("using all width & long label...",
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH));
// add another label that takes centered horizontally
vfm.add(new LabelField("horizontally centered...",
Field.FIELD_HCENTER));
vfm.add(new ButtonField("Go!!",Field.FIELD_HCENTER));
// add vfm to screen
add(vfm);
}
ありがとうございました。ボタンは表示されませんでした。私のコードが含まれています。 – ewom2468
行にブレークポイントを設定するvfm.add(新しいButtonField( "Go!"、FIELD_HCENTER));デバッグモードで実行すると、その行にコードが実行されていますか? – paulkayuk
私は自分のコードを改良し、マネージャー(上記のコードに含まれています)のボタンを中央に配置しました。次の問題は、ボタンのリスナーを作成する必要があることです。私はボタンリスナーを実装し、同時にマネージャを使用することはできますか? – ewom2468