- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
项目设置更新后,我收到此 NullPointerException[EDT] 0:0:0,0 - 代号一修订:e5578786e9d343acce705b819a37288d29591b72
[EDT] 0:0:0,71 - 异常:java.lang.NullPointerException - nulljava.lang.NullPointerException 在 com.codename1.ui.SideMenuBar$CommandWrapper.actionPerformed(SideMenuBar.java:1788) 在 com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:349) 在 com.codename1.ui.Button.fireActionEvent(Button.java:491) 在 com.codename1.ui.Button.released(Button.java:533) 在 com.codename1.ui.Button.pointerReleased(Button.java:637) 在com.codename1.ui.Form.pointerReleased(Form.java:2807) 在 com.codename1.ui.Component.pointerReleased(Component.java:4016) 在 com.codename1.ui.Display.handleEvent(Display.java:2032) 在 com.codename1.ui.Display.edtLoopImpl(Display.java:1028) 在 com.codename1.ui.Display.mainEDTLoop(Display.java:946) 在 com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120) 在 com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
代号one中似乎有一些东西。有谁知道怎么处理吗?
编辑。
好的@Shai,我想我找到了为什么你无法重现异常的原因。我已经安装了新插件 v3.8。名为“Forms Navigation”的示例模板现在生成与以前完全不同的代码。所以我认为你正在测试这个新代码,女巫在我的机器上工作得很好,但我已经在以前的示例代码之上构建了我的项目(见下文)。因此,如果我是正确的,请您尝试测试一下以前的代码,看看是否会遇到相同的异常。
package dk.cp3.anchorsafe;
import com.codename1.ui.Button;
import com.codename1.ui.CheckBox;
import com.codename1.ui.Display;
import com.codename1.ui.Form;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.util.Resources;
import com.codename1.ui.Command;
import com.codename1.ui.Dialog;
import com.codename1.ui.FontImage;
import com.codename1.ui.Image;
import com.codename1.ui.Label;
import com.codename1.ui.NavigationCommand;
import com.codename1.ui.RadioButton;
import com.codename1.ui.Slider;
import com.codename1.ui.TextField;
import com.codename1.ui.Toolbar;
import com.codename1.ui.events.ActionEvent;
import com.codename1.ui.events.ActionListener;
import com.codename1.ui.layouts.BoxLayout;
/**
* This file was generated by <a href="https://www.codenameone.com/">Codename One</a> for the purpose
* of building native mobile applications using Java.
*/
public class AnchorSafely {
private Form current;
private Resources theme;
private Form home;
public void init(Object context) {
theme = UIManager.initFirstTheme("/theme");
// Enable Toolbar on all Forms by default
Toolbar.setGlobalToolbar(true);
// Pro only feature, uncomment if you have a pro subscription
// Log.bindCrashProtection(true);
}
public void start() {
if (current != null) {
current.show();
return;
}
//create and build the home Form
home = new Form("Home");
home.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
home.addComponent(new Label("This is a Label"));
home.addComponent(new Button("This is a Button"));
TextField txt = new TextField();
txt.setHint("This is a TextField");
home.addComponent(txt);
home.addComponent(new CheckBox("This is a CheckBox"));
RadioButton rb1 = new RadioButton("This is a Radio Button 1");
rb1.setGroup("group");
home.addComponent(rb1);
RadioButton rb2 = new RadioButton("This is a Radio Button 2");
rb2.setGroup("group");
home.addComponent(rb2);
final Slider s = new Slider();
s.setText("50%");
s.setProgress(50);
s.setEditable(true);
s.setRenderPercentageOnTop(true);
home.addComponent(s);
Button b1 = new Button("Show a Dialog");
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Dialog.show("Dialog Title", "Dialog Body", "Ok", "Cancel");
}
});
home.addComponent(b1);
//Create Form1 and Form2 and set a Back Command to navigate back to the home Form
Form form1 = new Form("Form1");
setBackCommand(form1);
Form form2 = new Form("Form2");
setBackCommand(form2);
//Add navigation commands to the home Form
NavigationCommand homeCommand = new NavigationCommand("Home");
homeCommand.setNextForm(home);
home.getToolbar().addCommandToSideMenu(homeCommand);
NavigationCommand cmd1 = new NavigationCommand("Form1");
cmd1.setNextForm(form1);
home.getToolbar().addCommandToSideMenu(cmd1);
NavigationCommand cmd2 = new NavigationCommand("Form2");
cmd2.setNextForm(form2);
home.getToolbar().addCommandToSideMenu(cmd2);
//Add Edit, Add and Delete Commands to the home Form context Menu
Image im = FontImage.createMaterial(FontImage.MATERIAL_MODE_EDIT, UIManager.getInstance().getComponentStyle("Command"));
Command edit = new Command("Edit", im) {
@Override
public void actionPerformed(ActionEvent evt) {
System.out.println("Editing");
}
};
home.getToolbar().addCommandToOverflowMenu(edit);
im = FontImage.createMaterial(FontImage.MATERIAL_LIBRARY_ADD, UIManager.getInstance().getComponentStyle("Command"));
Command add = new Command("Add", im) {
@Override
public void actionPerformed(ActionEvent evt) {
System.out.println("Adding");
}
};
home.getToolbar().addCommandToOverflowMenu(add);
im = FontImage.createMaterial(FontImage.MATERIAL_DELETE, UIManager.getInstance().getComponentStyle("Command"));
Command delete = new Command("Delete", im) {
@Override
public void actionPerformed(ActionEvent evt) {
System.out.println("Deleting");
}
};
home.getToolbar().addCommandToOverflowMenu(delete);
home.show();
}
protected void setBackCommand(Form f) {
Command back = new Command("") {
@Override
public void actionPerformed(ActionEvent evt) {
home.showBack();
}
};
Image img = FontImage.createMaterial(FontImage.MATERIAL_ARROW_BACK, UIManager.getInstance().getComponentStyle("TitleCommand"));
back.setIcon(img);
f.getToolbar().addCommandToLeftBar(back);
f.getToolbar().setTitleCentered(true);
f.setBackCommand(back);
}
public void stop() {
current = Display.getInstance().getCurrent();
}
public void destroy() {
}
}
最佳答案
当我看到视频时,我注意到您使用了商业主题,我认为这不是问题的原因,但事实确实如此。业务主题定义了已弃用的 commandBehavior
主题常量,您只需删除该常量即可解决此问题。
关于java - 更新后 codename1 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47141271/
此问题仅针对代号一。 用例 一些应用程序,如 Instagram,具有 x 轴可滚动框,如本视频所示: https://www.informatica-libera.net/videoLavoro/V
您好,我正在使用 Codename One 和 Parse Server 将数据库保存在我的移动应用程序中,但我想将查询的每个结果放在一个按钮中,因为我需要单击列表中的每个元素。 ParseQuery
我创建了一个自定义日历,每当我单击日历按钮时,我都会尝试调用选择器,但它对我不起作用,以下是我的应用程序代码,该代码无法正常工作。那么我如何修改此代码以便能够从 ActionEvent 调用选取器?
有时,在决定如何构建图形界面之前,查阅 Codename One 提供的组件列表很有用。我有以下 list 。你能告诉我它是绝对完整的还是遗漏了什么?谢谢 Labels Label
我正在尝试使用CodeName One构建一个非常简单的用户界面。我想要一个矩形屏幕(用于显示图像)和其下方的按钮。我找不到类似矩形屏幕面板的东西,所以我只是贴了一个标签。 层次结构如下所示: 容器(
我正在尝试向标题/标题栏添加一个图标。 用代码更改标题本身效果很好: setTitle("测试"); 但是我无法找到向其添加图标的方法。这是我尝试过的方法,但没有成功: Image img =
我试图通过它的 CodeName 属性引用新添加的工作表。问题是 CodeName 返回空字符串,除非从调试器运行。 Set tableSheet = Worksheets.Add(After:=Wo
有没有办法在 Picker 组件中将选定的文本显示为多行? Picker 组件从 Button 扩展而来,它似乎不是一种将文本显示为多行的简单方法。 最佳答案 您可以克隆 Picker 类并将其命名为
我的应用程序使用 cn1-codescan.cn1lib 返回不受支持。当我使用已弃用的 CodeScanner (com.codename1.codescan.*) 时,扫描仪应用程序可以工作,但永
我已经创建了一个表单并添加了一个容器。我正在尝试使用此代码向容器中添加一个组件 Component container = new Container(new GridBagLayout())
我的应用程序使用一种表单,导航包括替换主容器。我有一个带有侧菜单、 Logo 、后退和退出命令的工具栏。我想在某些特定页面中禁用后退命令。command.setEnabled(false) 不起作用,
我刚刚在 Eclipse Oxygen 上安装了 Codename One(通过 eclipse 市场),并在 64 位 Ubuntu 14.04 LTS 下安装了 Java 8。我按照“入门”说明创
上下文: 开始为 android 和 ios 编写移动应用程序。 寻找许多替代方案。受不了 html5/webview 的东西。大多数时候它是缓慢的。我尝试了很多演示应用程序(phonegap/ste
也许我只是很难理解它。我从我所做的研究中了解它是如何工作的,尤其是这个问题:How does Codename One work? 但是如果我想拦截 Android 中的传入文本怎么办?这对 iOS
我在使用代号为 1 的 android 拦截 url 时遇到问题。我使用构建提示 ios.urlScheme 和 ios.plistInject 使其在 ios 上运行良好。我用于 android 的
我正在尝试了解如何使用 Codename One 服务器推送正确的通知。我想发送基本上看起来像 LocalNotifications 的通知- 带有标题、正文、角标(Badge)等。 然而在docum
我想在我的代号 One 应用程序中添加一个帮助屏幕。由于文本与其他字符串一样长,我想将它放在一个单独的文件中并将其添加到应用程序包中。 我该怎么做?将文本文件放在哪里,如何轻松地将其一次性读取到字符串
我有一个带有文本字段的 Android 应用程序。当我开始打字时,键盘将背景图像向上推。 我希望图像保留在原位,而键盘覆盖它。 将布局更改为 BoxLayout 或 BorderLayout 对背景图
我正在使用 Codename One 从数据库中获取数据并将其显示在表格中。 它运行良好,现在我正尝试添加一个功能来限制表格中显示的项目数量。为此,我想从数据库中检索选定数量的列。 不幸的是,常见的j
Toolbar API没有任何方法可以在左侧或右侧添加按钮(除了 SideMenus 内部)。它只允许添加命令,但命令不如按钮有用,因为我不能单独设置每个命令的样式,而我可以使用按钮来做到这一点。所以
我是一名优秀的程序员,十分优秀!