2017-04-10 36 views
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); 
} 
+0

哪些设备是这个失败? Android,iOS等。? –

+0

android三星... J7总理和其他三星设备 –

回答

1

谢谢。这看起来像是选择器的Android实现中的一个错误。我在github中有fixed这个,它将包含在星期五的下一个服务器更新中。