- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
示例代码如下:
package com.javafxportslistviewdemo;
import com.gluonhq.charm.down.Platform;
import com.gluonhq.charm.down.Services;
import com.gluonhq.charm.down.plugins.LifecycleEvent;
import com.gluonhq.charm.down.plugins.LifecycleService;
import javafx.application.Application;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Rectangle2D;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.VBox;
import javafx.stage.Screen;
import javafx.stage.Stage;
public class JavaFXPortsListViewDemo extends Application {
@Override
public void init() {
}
@Override
public void start(Stage primaryStage) throws Exception {
Screen primaryScreen = Screen.getPrimary();
Rectangle2D visualBounds = primaryScreen.getVisualBounds();
double width = visualBounds.getWidth();
double height = visualBounds.getHeight();
Label label = new Label("Here is selected item...");
ListView<String> listView = new ListView<>();
ObservableList<String> items = FXCollections.observableArrayList(
"one", "two", "three", "four");
listView.setItems(items);
listView.getSelectionModel().selectedItemProperty().addListener((ObservableValue<? extends String> ov, String old_val, String new_val) -> {
label.setText(new_val);
});
VBox root = new VBox();
root.getChildren().addAll(label, listView);
Scene scene = new Scene(root, width, height);
Services.get(LifecycleService.class).ifPresent(ls -> {
ls.addListener(LifecycleEvent.PAUSE, () -> onPause());
ls.addListener(LifecycleEvent.RESUME, () -> onResume());
});
scene.addEventHandler(KeyEvent.KEY_RELEASED, e -> {
if (KeyCode.ESCAPE.equals(e.getCode())) {
if (Platform.isAndroid()) {
// bring up the menu or other Android stuff
Services.get(LifecycleService.class).ifPresent(LifecycleService::shutdown);
} else {
// bring up the menu or other Desktop stuff
Services.get(LifecycleService.class).ifPresent(LifecycleService::shutdown);
}
}
});
primaryStage.setScene(scene);
primaryStage.show();
}
private void onPause() {
}
private void onResume() {
}
}
开发环境:JavaFXPorts 8.60.8、javafxmobile-plugin 1.1.0、Gluon Plugin 2.4.0、NetBeans 8.1、Windows 10 Pro,64 位
测试环境:Android设备Samsung Galaxy A5 2016,Android 6.0.1
重现步骤:1. 使用以下代码构建示例代码:JavaFXPorts 8.60.8、javafxmobile-plugin 1.1.0、Gluon Plugin 2.4.0; 2. 在Android设备(Android 6.0.1)上安装并运行示例; 3. Touch on ListView and Select any item from ListView - item is not selected -> BUG
为 JavaFXPorts 的问题跟踪器添加了错误:JavaFXPorts issue
最佳答案
感谢您报告问题。
众所周知,在某些三星设备中,触摸事件处理与其他 Android 设备不同。
虽然这在 JavaFXPorts 中已修复,但您可以使用以下解决方法:为在内部连接选择的 ListCell
提供一个监听器。
根据您的样本:
ListView<String> listView = new ListView<>();
listView.setCellFactory(p -> new ListCell<String>() {
private String item;
{
setOnMouseClicked(e -> listView.getSelectionModel().select(item));
}
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
this.item = item;
setText(item);
}
});
listView.getSelectionModel().selectedItemProperty()
.addListener((ov, old_val, new_val) -> label.setText(new_val));
关于JavaFXPorts:未选择 ListView 中的选定项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40482508/
我目前正在努力解决可能非常简单的问题:如何将一个 JavaFXPorts 特定项目用作另一个同类项目中的依赖项? 对于纯粹分离的项目,我不知道如何将它们组合起来(不得不承认,我对 Gradle 的了解
我的项目具有语言相关文本的属性文件,这些文本在 ISO-8859-1 中编码(默认从内容类型派生)。它们是使用ResourceBundle读取的。当我在 Android 上运行该应用程序时,我看到不可
请查看图像以获取代码引用: 如果运行上面的代码,TextArea 显示File Exists: false。 请注意:此代码有效:ImageView image = new ImageView(new
您好,我正在尝试开始使用 javafxports 为 Android 构建应用程序,我有 android sdk 和 gradle(尝试使用 2.3 和 2.2)从获取站点的起始页构建简单的应用程序,
我目前正在使用 GluonHQ 和 JavaFXPorts 使用 JavaFX 开发移动应用程序。我的其中一个屏幕包含一个 ListView ,您可以从下面的屏幕截图中看到,该屏幕截图是从我的 iPh
示例代码如下: package com.javafxportslistviewdemo; import com.gluonhq.charm.down.Platform; import com.gluo
我有一个基于 JavaFX 的界面,我正在尝试使用 JavaFXPorts 在多个平台上构建该界面。大多数代码是与平台无关的,但我有一些调用特定于平台的代码的实用程序,例如Android 与桌面上的文
我已经开始尝试获取有关此问题的一些信息(请参阅 here ),但这一次,我创建了一个示例应用程序来展示我的问题(希望以比上次更好的方式)。 在我开始之前,这里是应用程序存储库的链接: https://
我想用 JavaFXPorts 构建一个 JavaFX Android 应用程序和 Kotlin 代码。是否可以在 JavaFXPorts 项目中使用 Kotlin?这是我的示例 Gradle(版
我正在尝试使用 javafxports 从 javaFX 项目构建 Android 应用程序。目前,我在移动设备上安装并启动它时遇到问题,它抛出 ConfigurationException。 这是使
我在将 Javafx 应用程序构建到 Android 时遇到以下异常。 error: Error: No resource found that matches the given name (at
我将使用 sqlite 编写示例代码,它必须适用于 Android 和 IOS(和桌面) 这是我的build.gradle buildscript { repositories {
有没有办法访问 UIViewController,舞台正在运行?据我所知,在 RoboVM 和 Android 上有类似的东西,我们有 FXActivity 来完成这样的任务...... 感谢和问候,
我在使用 JavaFxPorts 在 Android 上保存文件时遇到问题。 我找到了那个链接 here ,但这对我不起作用。 它没有找到接口(interface),我无法使用它。 我的目标是使用 J
我使用 javafxports 和 gradle 在 netbeans 中编写了一个 javafx andoid 应用程序。我将依赖项添加到 gradel,但现在我不知道如何将 jars 添加到我的项
我在开发要移植到 Android 的 Javafx 应用程序时使用了 Netbeans 的 Gluon 插件,我想在 Android 的 Assets 文件夹中添加一些文件,但我找不到它?在哪里放置
我正在尝试使用 JavaFXPorts 和 RoboVM-cocoatouch 但我无法使用 RoboVM 中的原生内容,例如 UIButton。 我的 build.gradle 文件中有以下依赖项:
我想创建一个使用 MySqlDB 连接的应用程序/桌面应用程序。我在 Netbeans 中使用了 Gluon 插件。当我想编译桌面应用程序时,一切正常。但是当我想编译 Android 应用程序时 ->
在 Android 手机上启动我的应用程序时出现以下错误 FATAL EXCEPTION: main Process: ie.murphysoftware.games.magnatron, PID:
我正在尝试使用 javafxports 编写一个简单的 sqlite 代码。 build.gradle: buildscript { repositories { jc
我是一名优秀的程序员,十分优秀!