我正在尝试将内容的字符串放入ListView。运行代码后,ListView的对象包含null。我不确定问题出在哪里?任何帮助,请!不要忘了该员工,它是TabLayout中Tap类的对象。
//Step 1. Create and initialize the array.
String[] temp = {"Book", "Notebook", "pen", "pencil"};
//Step 2. Convert the array to ObservablList
ObservableList<String> strList = FXCollections.observableArrayList(temp);
//Step 3. Convert the ObservableList to ListView
ListView<String> listView = new ListView<>(strList);
//Step 4. Add the content of ListView to the employee Tap.
employee.setContent(listView);
在执行步骤4时抛出异常。我认为这是由于步骤3发生的。元素ListView的对象为null。