1
我使用picker.setStrings()方法。当字符串数组中有多个值时它工作正常,但当数组中只有一个元素时什么都不做。在下面的代码中,如果我取消对注释语句的注释,它将正常工作(显示对话框中的否),但有一个元素不起作用(在对话框msg中显示空白)。 PS。它在模拟器中正常工作,但在设备中存在这个问题。拾取器不工作时,它只有一个值
Picker stationPicker = new Picker();
stationPicker.setType(Display.PICKER_TYPE_STRINGS);
stationPicker.setSelectedString("Select the service center");
stationArray = new String[1];
stationArray[0] = "abc";
// stationArray[1] = "def";
stationPicker.setStrings(stationArray);
stationPicker.getParent().revalidate();
stationPicker.addActionListener(e -> {
stationIdArray = new String[1];
// stationIdArray = new String[2];
stationIdArray[0] = "1";
// stationIdArray[1] = "2";
if (stationArray != null) {
for (int i = 0; i < stationArray.length; i++) {
if (stationPicker.getSelectedString().equals(stationArray[i])) {
selectedStationId = stationIdArray[i] + "";
}
}
}
Dialog.show("Result", selectedStationId, "ok", null);
}
哪些设备是这个失败? Android,iOS等。? –
android三星... J7总理和其他三星设备 –