复制到剪贴板不起作用于Android
使用此视图创建标准移动应用程序:
public class DebugView extends View {
ListView<String> console = new ListView<>();
private DebugView() {
setCenter(console);
console.getItems().add("A");
console.getItems().add("A2");
console.getItems().add("A3");
console.getItems().add("A4");
var copyButton = new Button("Copy");
copyButton.setOnAction(e -> {
String log = console.getItems().stream().collect(Collectors.joining(System.lineSeparator()));
var content = new ClipboardContent();
content.putString(log);
Clipboard.getSystemClipboard().setContent(content);
var message = new Toast("Copied to clipboard");
message.show();
});
setBottom(copyButton);
}
}
在桌面上运行它,然后按复制按钮,您可以将内容粘贴到文本编辑器中。
在Android上运行它,然后按复制按钮,您无法将内容粘贴到Gmail等其他应用程序中。您以前的复制内容(如果存在)将被粘贴,因此看来剪贴板上没有任何内容,或者剪贴板不可用。
如何使剪贴板
在移动设备上工作?
使用
<javafx-maven-plugin-version>0.0.8</javafx-maven-plugin-version>
<gluonfx-maven-plugin-version>1.0.14</gluonfx-maven-plugin-version>
<java-version>17</java-version>
<javafx-version>18.0.1</javafx-version>
<charm-version>6.1.0</charm-version>
<attach-version>4.0.14-SNAPSHOT</attach-version>
和graalvm-svm-java17-linux-gluon-22.1.0.1-Final
Create a standard mobile application with this view:
public class DebugView extends View {
ListView<String> console = new ListView<>();
private DebugView() {
setCenter(console);
console.getItems().add("A");
console.getItems().add("A2");
console.getItems().add("A3");
console.getItems().add("A4");
var copyButton = new Button("Copy");
copyButton.setOnAction(e -> {
String log = console.getItems().stream().collect(Collectors.joining(System.lineSeparator()));
var content = new ClipboardContent();
content.putString(log);
Clipboard.getSystemClipboard().setContent(content);
var message = new Toast("Copied to clipboard");
message.show();
});
setBottom(copyButton);
}
}
Run it on desktop and press the Copy button, you can paste the contents into a text editor.
Run it on Android and press the Copy button, you can't paste the contents into another app, like Gmail. Your previous copied content (if exists) will be pasted, so it appears that nothing is added to the clipboard, or that the clipboard is not available.
How to make Clipboard
work on mobile?
Using
<javafx-maven-plugin-version>0.0.8</javafx-maven-plugin-version>
<gluonfx-maven-plugin-version>1.0.14</gluonfx-maven-plugin-version>
<java-version>17</java-version>
<javafx-version>18.0.1</javafx-version>
<charm-version>6.1.0</charm-version>
<attach-version>4.0.14-SNAPSHOT</attach-version>
and graalvm-svm-java17-linux-gluon-22.1.0.1-Final
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
附件的版本
4.0.14-snapshot
不支持Android剪贴板。版本4.0.15-snapshot
添加了功能性代码> 4.0.15 已在此支持下发布。The version of Attach
4.0.14-SNAPSHOT
did not support Android clipboard. Version4.0.15-SNAPSHOT
added the functionality and4.0.15
has been released with this support.