0

カスタム ドロップダウン メニューを持っています。メニューから 2 番目のオプションを選択するとフィールドが追加され、メニューから最初のオプションを選択すると同じフィールドが追加されます。これが私のカスタムドロップダウンです。

       public FWCustomChoiceField(final Object choice[]) {
    edit_field = GlobalUtils.getImage(Display.getWidth() + "x"+ Display.getHeight() + "bb_dropdown1.png");

    this.choice = new Object[choice.length];
    this.choice = choice;
    text = choice[0].toString();
    choiceField = new ListField() {
        protected boolean navigationClick(int status, int time) {
            //buttonIndexFunctionality(getSelectedIndex());

            Field focus = UiApplication.getUiApplication().getActiveScreen().getLeafFieldWithFocus();
            if (focus instanceof ListField) {
                ChoicePopupScreen popup = new ChoicePopupScreen(20, Display.getHeight()/ 2 - (choice.length * 20), choice);
                popup.setChoice(choice);
                UiApplication.getUiApplication().pushScreen(popup);
            }
            return super.navigationClick(status, time);
        }
    };



    choiceField.setSize(1);
    choiceField.setCallback(new TestListCallback());
    add(choiceField);
    invalidate();
}
    public int getListFieldIndex()
{

    return choiceField.getSelectedIndex();
}

public void setSelIndex(int index) {
    this.index = index;
    this.text = choice[index].toString();
    choiceField.invalidate();
}

public String getValue() {
    String value = choice[index1].toString();
    return value;

}

public int getSelectedIndex() {
    return index;
}

検索したところ、実行時に画面を再構築する必要があることがわかりましたが、その方法がわかりませんでした。

4

1 に答える 1

0

最初にフィールド マネージャーを作成し、画面に追加します。

 VerticalFieldManager title1;
 title1=new VerticalFieldManager(FIELD_HCENTER)
           {

           };
 title1.add(new NullField());
 add(title1);

ドロップダウンで 2 番目の項目を選択したら、次の操作を行います。

title1.deleteAll();
title1.add(add your field);//here add your field to title1.
title1.invalidate();

ドロップダウンの最初の項目をクリックすると、-

title1.deleteAll();
title1.invalidate();
于 2013-02-12T06:01:29.517 に答える