gpt4 book ai didi

blackberry - PopUpScreen 中的问题

转载 作者:行者123 更新时间:2023-12-02 00:23:44 25 4
gpt4 key购买 nike

单击图像时,我弹出一个带有下拉代码的屏幕,我必须在其中选择数据并将其从弹出的位置传递到屏幕,从下拉列表中选择数据后,弹出屏幕应该消失选定的 ocf 值到第一个屏幕。选择后我无法隐藏弹出屏幕,也无法将数据传回第一个屏幕

此代码将调用弹出屏幕

if (field==bitmapField1) {
UiApplication.getUiApplication().pushScreen(new MyPopup());
}

这是弹出的画面

public class MyPopup extends PopupScreen {
ObjectChoiceField ocf;

public MyPopup() {
super(new VerticalFieldManager(), Field.FOCUSABLE);
// this listener 'listens' for any event (see at the bottom)
FieldListener listener = new FieldListener();

TimeZone[] zone = TimeZoneUtilities.getAvailableTimeZones();
ocf = new ObjectChoiceField("Set Timezone", zone);
ocf.setChangeListener(listener);
add(ocf);
}

class FieldListener implements FieldChangeListener {
public void fieldChanged(Field f, int context) {
if (f == ocf) {
Object ob = ocf.getChoice(ocf.getSelectedIndex());
String str = ob.toString();
Dialog.alert(str);
}
}
}
}

最佳答案

您应该向 PopUpScreen 添加一个属性,该属性引用启动 PopUp 的屏幕。这样,您就可以毫无问题地将参数发送到父屏幕:

public class MyPopup extends PopupScreen {
ObjectChoiceField ocf;
MainScreen parentScreen;

public MyPopup(MainScreen parentScreen) {
this.parentScreen = parentScreen;
...

当您启动 PopUp 时:

if(field==bitmapField1){
UiApplication.getUiApplication().pushScreen(new MyPopup(this));
}

关于blackberry - PopUpScreen 中的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9772934/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com