English 中文(简体)
• 如何在Sevas建立多个检查箱
原标题:How to create multiple checkbox in canvas

在我试图在信道上建立一个检查箱时,我遇到麻烦。

我的检查箱运转良好,但我不知道如何储存每个项目的价值,这意味着当用户检查第1行时,然后转到另一个浏览箱,仍然检查第1行和2行的用户,然后转到另一行,检查箱将检查第1和第2行。

但我无法找到解决这一问题的办法。

最佳回答

修改您的代码,以使用。 about array array

    // ...initialization of DataList
    boolean[] selectTodelete = new boolean[2]; // instead of int
    { selectTodelete[0] = selectTodelete[1] = false; } // init array
    Command editCommand, backCommand,selectCmd, unselectCmd,selectAll;
    //...

    protected void paint(Graphics g) {
        //...
        for(int i =0 ; i<countRow; i++ ){
            //draw background
            //...
                     if(selectTodelete[i]){ // was selectTodelete == 1
                            //draw select dot at location for row  i 
                            //...
                     }
            // remove: you don t need that anymore: if(selectTodelete == 2) {
                            //draw select dot...
            //}

            // draw a checkbox before each item
            // ...
        }
    }

    public void commandAction(Command c, Displayable d) {
        //...
        if(c == selectCmd){
            selectTodelete[selectedItem] = true;
        }
        if(c== unselectCmd){
            selectTodelete[selectedItem] = false;
        }
        if(c == selectAll){
            selectTodelete[0] = selectTodelete[1] = true;
        }
        repaint();
    }
    //...
}

update - answer to question in comments

我想让国际协力事业团进行核查,这意味着当监听时,我会得到这种检查,而当我删除指挥时,它将删除所有囚室。

为此,你可以发现<条码>选择Todelete,在课外使用,但需使用以下方法:

    boolean isSelected(int elementNum) {
        return elementNum >= 0 && elementNum < selectTodelete.length
                && selectTodelete[elementNum];
    } // modelled after javax.microedition.lcdui.Choice.isSelected

......在你需要时,如在以下方法中,可进一步利用类似信息:

    Vector useSelection(DataList dataList, DataStore[][] ds) {
        Vector result = new Vector();
        int count = ds.length;
        for(int i = 0; i < count; i++ ) {
            if (!dataList.isSelected(i)) {
                continue; // skip non selected
            }
            System.out.println("RCID selected: [" + ds[i][5].cellText + "]");
            result.addElement(ds[i][5]);
        }
        return result;
    }
问题回答

暂无回答




相关问题
add text in http request string url

ok i made a midlet through which i can connect to server pages and get soem information as response. For example i made a midlet through which i acced url: http://example.com/?u=nepal&t=1 Now i ...

Do I have to do a setSize() on a Vector before using it?

Given private final Vector v = new Vector(); //instance variable the following 3 lines are in an instance method in the same class. 1. int length = v.capacity(); 2. int size = v.size(); ...

Is the situation with Java ME improving?

It seems to be the consensus that developing for Java ME is not as cross platform as you might expect, particularly compared to say java SE, but it is difficult to assess how the situation is evolving....

Privileged operations in netbeans mobility

I m writing a Java ME app that will use privileged operations such as messaging. By default the user is prompted to confirm each of these operations, but I would like to run it as a background ...

ClassFormatError: 56 while using hessian in j2me

I am trying to use the hessian j2me implementation @ http://hessian.caucho.com/ using java me sdk 3.0. http://hessian.caucho.com/doc/hessian-overview.xtp#Hessian%20Client%20for%20a%20cell-phone ...

热门标签