0
我是黑莓手机新手,在一个地方被卡住了。我有一个自定义的下拉菜单,我希望如果我从菜单中选择第二个选项,应该添加一个字段,如果我从菜单中选择第一个选项,字段应该删除。这是我的自定义下拉菜单。如何在黑莓运行时添加一个字段?
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;
}
我搜索并发现我需要在运行时重建屏幕,但无法弄清楚如何去做。
添加现场经理(hfm/vfm)到屏幕上。如果您单击第二个菜单,请将相应的字段添加到字段管理器并使其无效。当您单击第一个选项时,请从字段管理器中删除该字段。 – Signare 2013-02-12 05:26:20
我正在做同样的事情,但无法在运行时做到这一点。当我点击提交按钮比字段添加。 – MRX 2013-02-12 05:29:39
当您点击下拉菜单时,您想更改字段?是在运行时间? – Signare 2013-02-12 05:32:23