public Long[] getTimestamps() { Long[] timestamps = new Long[data.length]; int i = 0; for (SampleModel sm : data) { timestamps[i++] = sm.getTimestamp(); } return timestamps; }
// 为控件设置数据 @Override public void onBindViewHolder(ViewHolder viewHolder, int i) { // 获取当前item中显示的数据 final SampleModel rowData = sampleData.get(i); // 设置要显示的数据 viewHolder.textViewSample.setText(rowData.getSampleText()); viewHolder.itemView.setTag(rowData); }
public SampleModelCollection timestamp(Long... timestamps) { if (data.length != timestamps.length) { throw new IllegalArgumentException( "The number of supplied values do not match the data to be timestamped"); } int i = 0; for (SampleModel s : data) { s.setTimestamp(timestamps[i++]); } return this; }
@Override public void initUI() { AnchorPane anchorPane = new AnchorPane(); anchorPane.setPrefHeight(90.0); anchorPane.setPrefWidth(384.0); Label label = new Label(getApplication().getMessageSource().getMessage("name.label")); TextField input = new TextField(); input.setPrefWidth(200.0); Button button = new Button(); button.setPrefWidth(200.0); JavaFXUtils.configure( button, (JavaFXAction) actionFor(controller, "sayHello").getToolkitAction()); Label output = new Label(); label.setPrefWidth(360.0); model.inputProperty().bindBidirectional(input.textProperty()); model.outputProperty().bindBidirectional(output.textProperty()); anchorPane.getChildren().addAll(label, input, button, output); setLeftAnchor(label, 14.0); setTopAnchor(label, 14.0); setLeftAnchor(input, 172.0); setTopAnchor(input, 11.0); setLeftAnchor(button, 172.0); setTopAnchor(button, 45.0); setLeftAnchor(output, 14.0); setTopAnchor(output, 80.0); Tab tab = new Tab("Java"); tab.setGraphic(new FontAwesomeIcon(FontAwesome.FA_COFFEE)); tab.setClosable(false); tab.setContent(anchorPane); parentView.getTabPane().getTabs().add(tab); }
@Threading(Threading.Policy.INSIDE_UITHREAD_ASYNC) public void interact() { model.setInteractionCount(model.getInteractionCount() + 1); }
@Threading(Threading.Policy.INSIDE_UITHREAD_ASYNC) public void click() { model.setClickCount(model.getClickCount() + 1); }