J2ME comments order

I used several different types of commands, such as OK, CANCEL, BACK, EXIT, SCREEN in my application.

For instance,

exit = new Command("Exit", Command.EXIT, 5); _123=new Command("123",Command.BACK,4); ABC=new Command("ABC",Command.CANCEL,3); sample1=new Command("Sample1",Command.SCREEN,1); sample2=new Command("Sample2",Command.OK,2); 

I need an order: Sample1, Sample2, ABC, Exit. But it looks like this: Sample1, Sample2, Exit, ABC - the right side, and 123 - in the left side button.

Here, I also have one problem, adding another command (Edit_Cell), using as shown below ... and also I need to display first before Sample1. But it is displayed at the end of all teams on the right side.

I added this new command (Edit_Cell) to another constructor of the src file and is called by the constructor below my code (adding commands).

Edit_Cell is a type of SCREEN and PRIORITIES IS 1 in another source file.

I need my last order: Edit_Cell,Sample1,Sample2,ABC,Exit, on right hand side and _123 on the left side.

+4
source share
2 answers

I am responding to your comment here, it is less dirty ... Perhaps it displays the commands in the same order in which they were added (without using priorities). I would delete all the commands when Edit_Cell added, and add them again after adding Edit_Cell . If you can only change the form code, you can override the addCommand method to make sure that when you add Edit_Cell all previous commands are deleted and added later.

Something like that:

 @Override public void addCommand(Command cmd) { if (cmd.getLabel().equals("Edit_Cell")){ removeCommand(sample1); // with all the previously added commands } super.addCommand(cmd); if (cmd.getLabel().equals("Edit_Cell")){ addCommand(sample1); // again with all your previously added commands } } 

It's not very elegant, but well, you can always make it more cool if it works ...

0
source

First of all, and no offense, I think you should develop a little more of your written compositions, it took me some time to understand the problem.

However, the way you pretend to be a team makes sense according to this (Nokia wiki forum):

The display of commands for soft keys follows the following rules:

Right soft key : there can only be one "negative" command (STOP, CANCEL, BACK, EXIT in this priority order) is displayed on the right soft key, and the displayed command is directly called by pressing the soft key.

Left soft key : Mutiple commands can be displayed under the left soft key, in which If on the left side there is a label “Parameters”, a soft key will appear and its selection of the command menu. If there is only one “positive” command (OK, ITEM, SCREEN or HELP) on the left, the soft key will be represented directly on the left soft key. (Note: some LCDUI components have their own operations that will also be visible on the left in this way, invoking the options menu.) If there is more than one negative command, this will cause the Options menu to the left of the softkey and the commands will be presented in the order below.

Middle function key . In the 40 series, only a single context-sensitive command (OK, ITEM) is mapped to the middle soft key. In S60 with several context-sensitive Commands (OK, ITEM) you can map to the Middle soft key. If only one Command will be shown directly in, otherwise the command visible in the context-sensitive menu is open with the middle softkey. As usual, the same commands that are mapped to the middle softkey are also available on the left (directly or via the menu option). Note. Some user interface components override this rule and place the component specific operation directly for the middle function key. For example, the POPUP ChoiceGroup has an Open operation in the Middle softkey.

Obviously, this is highly platform dependent, but it looks like your midlet accepts _123 as a negative command, and everyone else is placed on another softkey.

I would try changing the types and prioritizing as you wish ... something like this

 exit = new Command("Exit", Command.EXIT, 5); _123=new Command("123",Command.BACK,0); ABC=new Command("ABC",Command.SCREEN,3); sample1=new Command("Sample1",Command.SCREEN,1); sample2=new Command("Sample2",Command.OK,2); 

And you can set the Edit_Cell priority to 0, and its type is SCREEN . And just add: ITEM usually put teams.

Hope this helps. Best wishes.

+5
source

Source: https://habr.com/ru/post/1335037/


All Articles