1

動作していません:

final Object[] stringsMenu;
Vector auxMenu = new Vector();
final IntVector optionsMenu = new IntVector();
        auxMenu.addElement("ficha");
        optionsMenu.addElement(1);
        auxMenu.addElement("ficha2");
        optionsMenu.addElement2);
        auxMenu.addElement("ficha3");
        optionsMenu.addElement(3);
    UiApplication.getUiApplication().invokeLater(new Runnable()
    {
        public void run()
        {
        try
        {
            int[] optionsintMenu = optionsMenu.getArray();
                    switch (Dialog.ask("Info:", stringsMenu, optionsintMenu, 0))
                    {
                      ...
                    }
                }
            }
        } ..................

働く

final Object[] stringsMenu;
Vector auxMenu = new Vector();
final IntVector optionsMenu = new IntVector();
        auxMenu.addElement("ficha");
        optionsMenu.addElement(1);
        auxMenu.addElement("ficha2");
        optionsMenu.addElement2);
        auxMenu.addElement("ficha3");
        optionsMenu.addElement(3);
    UiApplication.getUiApplication().invokeLater(new Runnable()
    {
        public void run()
        {
        try
        {
                    switch (Dialog.ask("Info:", stringsMenu, new int[]{1,2,3}, 0))
                    {
                      ...
                    }
                }
            }
        } .....................

内部 IndexoutofboundsException が発生しています。何が起こっているのか考えていますか?

4

1 に答える 1

1

getArray()使用しようとする代わりにtoArray()

ドキュメントによると:

toArray :

public int[] toArray()

基になるストアのコピーを取得します。結果の配列はトリミングされます。

getArray :

public int[] getArray()

ベクトル値を取得します。配列はトリミングされず、コピーではありません。

配列はトリミングされていません。おそらく indexOutOfBound を取得するのはそのためです

于 2012-06-18T13:13:24.213 に答える