开发者

Why the command button is not being displayed in my emulator?

I have already added 5 cammands in a form and I want to add a sixth but It does not display the sixth?

I am posting my codes below.

public Command getOk_Lastjourney() {
        if (Ok_Lastjourney == null) {
            // write pre-init user code here
            Ok_Lastjourney = new Command("Last Journey", Command.OK, 0);
            // write post-init user code here
        }
        return Ok_Lastjourney;
    }


public Form getFrm_planjourney() {
        if (frm_planjourney == null) {                                 
            // write pre-init user code here
            frm_planjourney = 开发者_JAVA百科new Form("Plan journey", new Item[] { getTxt_From(), getTxt_To(), getCg_usertype(), getCg_userpref(), getCg_searchalgo() });                                    
            frm_planjourney.addCommand(getExt_planjourney());
            frm_planjourney.addCommand(getOk_planjourney());
            frm_planjourney.addCommand(getOk_planFare());
            frm_planjourney.addCommand(getOk_planDistance());
            frm_planjourney.addCommand(getOk_planTime());
            frm_planjourney.addCommand(getOk_planRoute());
            frm_planjourney.setCommandListener(this);                                  
            // write post-init user code here
            System.out.println("Appending.....");

            System.out.println("Append completed...");
            System.out.println(frm_planjourney.size());
            frm_planjourney.setItemStateListener(this);
        }                         
        return frm_planjourney;
    }


Given System.out.println I assume you were debugging with emulator, right? in that case it would be really helpful to provide a screen shot showing how exactly does not display the sixth looks like.

Most likely you just got too many commands to fit to area allocated so that some of them are not shown until scrolled. There is also a chance that sixth command was reassigned to some other soft-button and you didn't notice that. Or there's something else - hard to tell with details you provided.

A general note - handling six actions with commands might be not the best choice in MIDP UI. For stuff like that, consider using lcdui List API instead. IMPLICIT kind of lists allow for more reliable and user friendly design than commands.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜