带有自定义对象的Gluon ListView在Android

时间:2017-10-31 20:21:15

标签: android listview javafx gluon

创建了自定义对象的ListView。在滚动列表视图时,看到该应用程序在Android上崩溃。

注意:ListView滚动正在处理胶子桌面应用程序:

用于创建ListView的控制器代码

  List<Map<String, String>> li = BinfMobileApp.service.getList();

    ObservableList<Map<String, String>> messages = FXCollections.observableArrayList();
    for (int i = 0; i < li.size(); i++) {
        messages.add(li.get(i));

    }
        ListView<Map<String, String>> messageList2 = new ListView<>(messages);

    messageList2.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);

    messageList2.setCellFactory(param -> new ListCell<Map<String, String>>() {
        @Override
        protected void updateItem(Map<String, String> item, boolean empty) {
            super.updateItem(item, empty);

            if (empty || item == null || item.get("SUBJECT") == null) {
                setText(null);
                setGraphic(null);
            } else {

                ListTile tile = new ListTile();
                tile.textProperty().setAll(item.get("SUBJECT"));
                tile.setPrefHeight(50);
                tile.setOnMouseClicked(new EventHandler<MouseEvent>() {

                    @Override
                    public void handle(MouseEvent event) {

                        selectedMessage = messageList2.getSelectionModel().getSelectedItem();
                        Parent home_page;
                        try {

                            home_page = FXMLLoader.load(getClass().getResource("messageDetail.fxml"));
                            Scene home_page_scene = new Scene(home_page);
                            Stage home_stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
                            home_stage.setScene(home_page_scene);
                            home_stage.show();
                        } catch (IOException ex) {
                            Logger.getLogger(SecondaryPresenter.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        System.out.println("clicked on " + messageList2.getSelectionModel().getSelectedItem().get("SUBJECT"));
                    }
                });
                setText(null);
                setGraphic(tile);

            }
        }

    }
    );

    messagesVBox.getChildren().add(messageList2);

Android错误日志:

10-31 15:09:59.250 1042 1072 I GLASS:调用InternalSurfaceView_onMultiTouchEventNative 10-31 15:09:59.250 1042 1072 I GLASS:玻璃会通过multitouchevent到unile,count = 1 10-31 15:09:59.251 1042 1072 I GLASS:调用InternalSurfaceView_onMultiTouchEventNative 10-31 15:09:59.251 1042 1072 I GLASS:玻璃会通过multitouchevent传递给figle = 1 10-31 15:09:59.252 1042 1072 I GLASS:调用InternalSurfaceView_onMultiTouchEventNative 10-31 15:09:59.252 1042 1072 I GLASS:玻璃会通过multitouchevent到unile,count = 1 10-31 15:09:59.252 1042 1072 I System.out:不添加点,primary = -1 10-31 15:09:59.270 908 922 W ActivityManager:强制完成活动com.binfermobileapp / javafxports.android.FXActivity 10-31 15:09:59.274 1042 1042 V FXActivity:onPause 10-31 15:09:59.293 908 942 I ActivityManager:显示包com.binfermobileapp u0的崩溃对话框

0 个答案:

没有答案