2
JavaFX - 我有一个类Record with一个方法(和其他功能)public String getName()
。我有ListView<Record> listview
,这里是显示Record
代码的名字:我如何更改ListView中的自定义项目
listview.setCellFactory(new Callback<ListView<Record>, ListCell<Record>>() {
public ListCell<Record> call(ListView<Record> param) {
final ListCell<Record> cell = new ListCell<Record>() {
@Override
public void updateItem(Record item, boolean empty) {
super.updateItem(item, empty);
if (item != null) {
setText(item.getName());
}
}
};
return cell;
}
});
可惜的是,如果我改变Record
的名字是这样的:
Record record = listview.getSelectionModel().getSelectedItem();
record.setName("New Name");
单元格文本不列表视图改变。我应该怎么做才能解决这个问题?或者我如何改变单元格的文字?
就像一个魅力更换线
!非常感谢你! – madox2 2013-03-24 12:24:48