"Reading Art" Development Environment (2)

xiaoxiao2021-03-06  107

First talk about the interface navigation problem

Every time I see the Menu, I feel very uncomfortable. I may be a ME quirk, but I only need to press "Menu" to find a function button, enter the option window (Note the currently browse page is covered), find the desired function key , Press, then result, more trouble.

The appearance of MENU is because the current Displayable (Sub-class is Screen and Canvas) more than two (at least two of the general mobile phones, according to Java DOCS, there are also three Soft Button) , ME did not have seen it, I don't think about it first). In this way, if you don't think "Menu", the current Displayable can only join two Command. But to achieve a complete reading program, just two command is definitely not enough. ME's solution is to define a command list, only two Command (later synonymous "on the displayable, and then use the button to perform the function button to review the command. On the left, the screen is fixed to the operation help, introduce the operation method, because this interface navigation update is definitely not immediately adapt to most of the friends, huh, huh; the other side of the screen, specifically, the phone is pressed To the right direction button, automatically change to the next Command of the command column, and the left button is automatically switched to the last Command. Oh, simple.

How to achieve is really a problem. Me thought that there should be such an article on the Internet, search for a long time, Google has a lot of results, useful, and it is very useful. However, a "Application MVC Design Mode" (http://blog.9cbs.net/mingjava/archive/2004/06/29/30053.aspx) looks like a very problem. Learned carefully, don't understand, the middle seems to design the design mode problem, this is not the current level of ME, huh, huh. However, it is not small to inspire the MIDlet as a parameter into the controller.

The class reference of the "Reading" program The general J2ME program is such a constituent mode, inherits from the main class readart from the MIDlet, inheriting subclass Artfield from Canvas (Sorry, still picking with that Timer routine, so called ... Field , 嘿嘿) as the main realistic canvas, and a custom Article class for organizational text, and other auxiliary classes. After turning over the DOCS, Displayable does not support the operation of the mobile phone keyboard, that is to say, such as pressing a key to change the Command. Therefore, to implement the rotation of the command column, you can only implement in Canvas because Canvas has the interface keypressed of the key action. You can know which key is pressed by a query of the key value, and then make a corresponding change. As for the passage of the command column, it is implemented by the build parameters of ArtFiled, that is, the CommandList is defined in the Readart, and then incorporated as builder parameters when generating ArtField, and then operates in the proTfield's keypressed.

Check the DOCS and find that CANVAS can directly implement CommandListener. Immediately, but don't display correctly when it is displayed, do not know that Canvas's support for CommandListener is limited or the method does not find a suitable method. In addition, this time ME found that Command did not support SetLabel, that is, once it generated Label, it would not be changed. This goes all the commands in the command column are all built, and then call it. In addition, Canvas supports Addcommand and RemoveCommand, this is good to do, huh, huh. Comprehensive issues, ME adjusts the strategy. "Help" and another default "next page" (because this most often used), then change the screen chasing Command, the method is first removeallCommand, then add the next one in the logic order. Or the last Command. Test, ok, huh, huh. Tent into a paragraph.

Specific code samples are as follows: / ** * ReadArt, main reading software * @author heart5 * @version start * / public class ReadArt extends MIDlet implements CommandListener {Display display; ArtField artf; About about; String [] cmdStrs = { " Help "," Next "," Previous "," Related Information "," Exit "}; Command Cmds []; ... public readart () {Display = Display.getDisplay (this); cmds = new Command [cmdSTRS.LENGTH]; for (int i = 0; i

转载请注明原文地址:https://www.9cbs.com/read-102905.html

New Post(0)