Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java me j2me中自定义GUI中的遍历_Java Me_Custom Controls_Midp_Lcdui - Fatal编程技术网

Java me j2me中自定义GUI中的遍历

Java me j2me中自定义GUI中的遍历,java-me,custom-controls,midp,lcdui,Java Me,Custom Controls,Midp,Lcdui,这是我的遍历方法代码 protected boolean traverse(int dir, int viewportWidth, int viewportHeight, int[] visRect_inout) { try { if (hori && vert) { // CustomItems items=new CustomItems("Hi"); switch (dir) {

这是我的遍历方法代码

protected boolean traverse(int dir, int viewportWidth, int viewportHeight,
        int[] visRect_inout) {
    try {
        if (hori && vert) {
            // CustomItems items=new CustomItems("Hi");
            switch (dir) {
                case Canvas.DOWN:
                    this.a=dir;                  //Canvas.DOWN
                    this.b=viewportWidth;        //b=2
                    this.c=viewportHeight;       //c=3 
                    this.d=visRect_inout;        //d={2,2,250,250}
                    this.traverse(Canvas.UP, b, c, d);

                    break;
                case Canvas.UP:
                    this.a=dir;
                    this.j=viewportWidth;
                    this.k=viewportHeight;
                    this.d=visRect_inout;  
                    this.traverse(Canvas.UP, j, k, d);
                    break;
                case Canvas.LEFT:
                    this.a=dir;
                    this.j=viewportWidth;
                    this.k=viewportHeight;
                    this.d=visRect_inout;
                    this.traverse(Canvas.LEFT, j, k, d);
                    break;
                case Canvas.RIGHT:

                    break;
            }
        }

    } catch (Exception e) {
        System.out.println("Exception " + e);
    }
    return false;
}
我对定制商品非常陌生。

如果我做错了什么,请告诉我。

从switch语句中调用
遍历
的方式在我看来很难理解:

                    this.traverse(Canvas.UP, b, c, d); // ...
                    // ...and similar in cases Canvas.UP, LEFT
到目前为止,您发布的代码非常零碎,但据我所知,上面的代码将导致无限次递归调用
遍历
,最终导致堆栈溢出错误

但在您的特定情况下,这可能是无害的,因为您无条件地从方法返回
false
。据我所知,这意味着设备将永远不会尝试使用
Canvas UP
和其他潜在的危险值调用traverse。如果您感兴趣,请随时查看更多详细信息

  • 考虑到您的代码,我认为学习教程中的介绍性代码示例是很有意义的。网上有很多类似“MIDP教程自定义项”的东西。下面是一个链接,例如:

    此外,如果您使用的是Wireless Toolkit/JavaMeSDK,则可以查看它们的代码示例。根据我的记忆,那里有一些很好的CustomItem代码的工作示例

什么是CustomGUI?什么是列表项?中没有此类对象。你的意思是
CustomItem
ChoiceGroup
?@user1078616,你的问题很模糊,没有结论。用更具体的上下文、屏幕截图、提及参考库和使用的开发环境来支持您的问题。