- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经学习 J2ME 有几天了。但我有一个大问题;我的移动应用程序大约有 5 个页面:第一个页面扩展了 MIDlet,而其他页面则扩展了表单。加载第一页后,我使用命令切换到其他页面,但是当我到达新页面(扩展形式)时,我附加的所有命令都没有响应。我需要深入了解解决这个问题。我的代码如下;
初始页面;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package report;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import org.netbeans.microedition.lcdui.SimpleTableModel;
import org.netbeans.microedition.lcdui.TableItem;
/**
* @author Possicon
*/
public class Reports extends MIDlet implements CommandListener {
private boolean midletPaused = false;
//<editor-fold defaultstate="collapsed" desc=" Generated Fields ">
private Form form;
private Command SendReport;
private Command SendPictureReport;
private Command exitCommand;
private Command viewReport;
private Command subscribe;
private Command spotted;
private Command sortBy;
private SimpleTableModel tableModel1;
//</editor-fold>
/**
* The Reports constructor.
*/
public Reports() {
//startMIDlet();
}
//<editor-fold defaultstate="collapsed" desc=" Generated Methods ">
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">
/**
* Initializes the application.
* It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
*/
private void initialize() {
// write pre-initialize user code here
// write post-initialize user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">
/**
* Performs an action assigned to the Mobile Device - MIDlet Started point.
*/
public void startMIDlet() {
// write pre-action user code here
getDisplay().setCurrent(getForm());
// write post-action user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">
/**
* Performs an action assigned to the Mobile Device - MIDlet Resumed point.
*/
public void resumeMIDlet() {
// write pre-action user code here
// write post-action user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">
/**
* Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
* @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
* @param nextDisplayable the Displayable to be set
*/
public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
// write pre-switch user code here
Display display = getDisplay();
if (alert == null) {
display.setCurrent(nextDisplayable);
} else {
display.setCurrent(alert, nextDisplayable);
}
// write post-switch user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">
/**
* Called by a system to indicated that a command has been invoked on a particular displayable.
* @param command the Command that was invoked
* @param displayable the Displayable where the command was invoked
*/
public void commandAction(Command command, Displayable displayable) {
// write pre-action user code here
if (displayable == form) {
if (command == SendReport) {
// write pre-action user code here
getDisplay().setCurrent(new SendReport());
// write post-action user code here
} else if (command == exitCommand) {
// write pre-action user code here
exitMIDlet();
// write post-action user code here
} else if (command == sortBy) {
// write pre-action user code here
// write post-action user code here
} else if (command == spotted) {
// write pre-action user code here
getDisplay().setCurrent(new Spotted());
// write post-action user code here
} else if (command == subscribe) {
// write pre-action user code here
//getDisplay().setCurrent(new Subscribe());
new Subscribe().getMyDisplay(getDisplay());
// write post-action user code here
}
}
// write post-action user code here
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: form ">
/**
* Returns an initiliazed instance of form component.
* @return the initialized component instance
*/
public Form getForm() {
if (form == null) {
// write pre-init user code here
form = new Form("Traffic Reports", new Item[] { });
form.addCommand(getSortBy());
form.addCommand(getSendReport());
form.addCommand(getSubscribe());
form.addCommand(getExitCommand());
form.addCommand(getSpotted());
form.setCommandListener(this);
// write post-init user code here
loadReports(form);
//form.append(getTableModel1());
}
return form;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: SendReport ">
/**
* Returns an initiliazed instance of SendReport component.
* @return the initialized component instance
*/
public Command getSendReport() {
if (SendReport == null) {
// write pre-init user code here
SendReport = new Command("Send Report", Command.SCREEN, 0);
// write post-init user code here
}
return SendReport;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: SendPictureReport ">
/**
* Returns an initiliazed instance of SendPictureReport component.
* @return the initialized component instance
*/
public Command getSendPictureReport() {
if (SendPictureReport == null) {
// write pre-init user code here
SendPictureReport = new Command("Send Picture Report", Command.SCREEN, 0);
// write post-init user code here
}
return SendPictureReport;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: tableModel1 ">
/**
* Returns an initiliazed instance of tableModel1 component.
* @return the initialized component instance
*/
public SimpleTableModel getTableModel1() {
if (tableModel1 == null) {
// write pre-init user code here
tableModel1 = new SimpleTableModel(new java.lang.String[][] {
new java.lang.String[] { "Traffic on Ikorodu road, free" },
new java.lang.String[] { "Adeola Odeku is free" },
new java.lang.String[] { "Accident on Ahmadu Bellow" }}, null);
// write post-init user code here
}
return tableModel1;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: exitCommand ">
/**
* Returns an initiliazed instance of exitCommand component.
* @return the initialized component instance
*/
public Command getExitCommand() {
if (exitCommand == null) {
// write pre-init user code here
exitCommand = new Command("Exit", Command.EXIT, 0);
// write post-init user code here
}
return exitCommand;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: viewReport ">
/**
* Returns an initiliazed instance of viewReport component.
* @return the initialized component instance
*/
public Command getViewReport() {
if (viewReport == null) {
// write pre-init user code here
viewReport = new Command("View Reports", Command.SCREEN, 0);
// write post-init user code here
}
return viewReport;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: subscribe ">
/**
* Returns an initiliazed instance of subscribe component.
* @return the initialized component instance
*/
public Command getSubscribe() {
if (subscribe == null) {
// write pre-init user code here
subscribe = new Command("Subscribe", Command.SCREEN, 0);
// write post-init user code here
}
return subscribe;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: spotted ">
/**
* Returns an initiliazed instance of spotted component.
* @return the initialized component instance
*/
public Command getSpotted() {
if (spotted == null) {
// write pre-init user code here
spotted = new Command("Spotted", Command.SCREEN, 0);
// write post-init user code here
}
return spotted;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc=" Generated Getter: sortBy ">
/**
* Returns an initiliazed instance of sortBy component.
* @return the initialized component instance
*/
public Command getSortBy() {
if (sortBy == null) {
// write pre-init user code here
sortBy = new Command("Sort By", Command.SCREEN, 0);
// write post-init user code here
}
return sortBy;
}
//</editor-fold>
/**
* Returns a display instance.
* @return the display instance.
*/
public Display getDisplay() {
return Display.getDisplay(this);
}
/**
* Exits MIDlet.
*/
public void exitMIDlet() {
switchDisplayable(null, null);
destroyApp(true);
notifyDestroyed();
}
/**
* Called when MIDlet is started.
* Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
*/
public void startApp() {
if (midletPaused) {
resumeMIDlet();
} else {
initialize();
//Login displayed = Login.displayed(1);
//getDisplay().setCurrent(new Login());
startMIDlet();
}
midletPaused = false;
}
/**
* Called when MIDlet is paused.
*/
public void pauseApp() {
midletPaused = true;
}
/**
* Called to signal the MIDlet to terminate.
* @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
*/
public void destroyApp(boolean unconditional) {
}
public void loadReports(Form form){
String string[] ={"Traffic is here", "Traffic is bad here","Accident Occured here"};
StringItem st;
for(int i=0; i<string.length; i++){
st = new StringItem("",string[i]);
form.append(st);
}
}
/*
public Array fetchReports(){
}
*
*/
}
第二页;试图调用第一页;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package report;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.DateField;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemStateListener;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;
/**
* @author Possicon
*/
public class Subscribe extends Form implements CommandListener, ItemStateListener {
private Form form;
private StringItem label;
private Display display;
private Command save;
private Command subscribe;
private Command spotted;
private Command sendReport ;
private Command viewReport;
private Command exit;
private Command back ;
private TextField email, phone,route;
private DateField time , timet;
/*
public Subscribe(){
super("");
}
*
*/
public Subscribe() {
//display = Display.getDisplay(this);
//display = displ;
//form = new Form("Traffic Subscription");
super("Traffic Subscription");
label = new StringItem("Subscribe to recieve Traffic Alerts: ", "");
email = new TextField("Email: ", "", 50, TextField.EMAILADDR);
phone = new TextField("Phone: ", "", 11, TextField.ANY);
route = new TextField("Road: ", "", 20, TextField.ANY);
//twitter = new TextField("Twitter: ", "", 20, TextField.);
time = new DateField("Between: ", DateField.TIME);
timet = new DateField("To: ", DateField.TIME);
//DateFielddateField= new DateField(“Date:”, DateField.DATE);
java.util.Date date = new java.util.Date();
time.setDate(date);
append(label);
append(email);
append(phone);
append(route);
append(time);
append(timet);
save = new Command("Save", Command.SCREEN,1);
spotted = new Command("Spotted", Command.SCREEN,4);
sendReport = new Command("Send Report", Command.SCREEN,2);
viewReport = new Command("Reports", Command.SCREEN,3);
exit = new Command("Exit", Command.EXIT,0);
//back = new Command("Back", Command.BACK,0);
addCommand(exit);
addCommand(viewReport);
addCommand(sendReport);
addCommand(save);
addCommand(spotted);
//return form;
}
public void commandAction(Command command, Displayable dsplbl) {
if (command == sendReport) {
// write pre-action user code here
new Reports().switchDisplayable(null,new SendReport());
//display.setCurrent(new SendReport());
// write post-action user code here
} else if (command == exit) {
// write pre-action user code here
//exitMIDlet();
// write post-action user code here
} else if (command == spotted) {
// write pre-action user code here
display.setCurrent(new Spotted());
// write post-action user code here
}
}
public void itemStateChanged(Item item) {
}
public void save(){
}
}
最佳答案
在您的订阅表单中,您没有将 CommandListener 附加到您的订阅表单。因此,在表单上添加命令后,请像 this.setCommandListener(this);
那样附加 CommandListener谢谢
关于java - 在 J2ME 中链接多个页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6319276/
假设我有父页面。 当我单击“打印”时,会打开一个新选项卡(页面)以进行打印预览。 我想要的是,当我单击“打印”时,父选项卡(页面)上应显示覆盖层,以停止进一步的工作,直到子选项卡关闭。 Because
我知道这是不可能的,但我想我还是会问这个问题。 我有一个 HTTPS 页面,并且正在动态创建一个表单。我想将表单发布到 HTTP 页面。在浏览器不弹出警告的情况下这可能吗?当我在 IE8 上执行此操作
在我的应用程序中,我实现了ajax 4.0客户端模板 目前我的模板位于同一个.aspx页面上。 (例如 Main.aspx) 但我想将它们外部化。(即所有 HTML 都会放在另一个页面上) 为此,我使
我目前正在构建自己的网络应用程序。在此应用程序的标题中有一个导航栏。 我将相同的导航栏添加到我的所有 html 页面,以便在页面之间导航时保持可见,并将导航元素设置为事件到我现在所在的页面。 我的
我们有一个在集成管道下运行的 IIS7 Intranet 站点,该管道主要是 ASP.Net,带有一些传统的经典 ASP 页面。该站点允许匿名访问大多数区域,但使用 Windows 身份验证来保护某些
有一个要求,我需要根据 div 标签的高度超过 700 像素的条件将大型 HTML 页面拆分为多个页面。 我还可以根据字数拆分页面。 下面的示例根据 HTML 标签分割页面,而我需要根据 div 高度
有两个 html 页面,如果在第一个页面中单击特定图像,它将转到第二个 html 页面。如果在第二个 html 页面上的任何地方单击它应该返回到第一页并将第二页完全显示在第一页的一个 div 中 1s
我有一个简单的 hello world Servant 应用程序。我需要向它添加一些静态或动态的 html 页面。我怎样才能做到这一点?在文档中没有提到它。注意我不想在 Haskell 代码中创建 h
我有两个文件 index.html 和 index2.html。这两个文件都在本地机器上的同一目录中(无法访问 PHP 等)。 我正在努力 Page Title 使用 jQuery 从 index.h
假设我有一个 JSP 页面 index.jsp User id:
我面临着一个对我来说非常陌生的情况。我会尽力让事情变得简单来解释它一步一步来。 1)在页面 A(用户表单)中,我从字段中获取一些值并将其作为 jQuery AJAX POST 发送到页面 B。这是主要
我正在尝试弄清楚如何从 buttons.html 获取用户按钮点击动态切换第二个列的可见性 userinput.html 。我正在使用 DataTables userinput.html表并认为我有
我有asp。净 mvc4 项目。 Angularjs 已集成。 我已经按照以前的要求构建了 HTML 页面和 WEB API 2。 现在出于某种原因,我必须使用 CSHTML 页面。以前我只有 web
我的网站包含大约 18 个不同的页面。以管理员身份登录后,我单击“页面”。 我看到了以下内容 All (20) | Mine (19) | Published (19) | Draft (1) No
Haskell 中每个函数都有手册页吗?换句话说,我可以在某处输入 man fst 并获取有关该函数的手册或帮助页面吗?我发现大量的功能势不可挡! 我正在使用 GHC 和 GHCi。 最佳答案 我不知
我一直在用github pages很长一段时间以来,并使用自定义域重定向功能来重定向我的 user website来自 prahladyeri.github.io到我自己的域名 https://www
我对 Github 有一个基本的了解:我知道如何创建、添加、提交、推送和克隆存储库。我也开始探索 Github 页面来托管我的项目。我的最新项目于 3 月开始并将其推送到 gh-page。从那以后,我
在尝试查看日志时,Airflow 会抛出一个带有以下消息的 oops 页面: File "/Users/user/.pyenv/versions/3.5.2/lib/python3.5/locale.
我已经按照此处列出的步骤 (https://pages.github.com/) 为我正在处理的网站设置了一个 GitHub 页面 我设置的站点当前托管在 IIS 下,并使用 URL Rewrite
我想将我的 domain.com 重定向到 openshift 页面 (openshift-app.rhcloud.com)。我已经按照描述完成了 here它有效。唯一的问题是,在任何网站上,我都不会
我是一名优秀的程序员,十分优秀!