Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.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 子对象在管理器中的自定义位置(按坐标)_Java_Android_Blackberry - Fatal编程技术网

Java 子对象在管理器中的自定义位置(按坐标)

Java 子对象在管理器中的自定义位置(按坐标),java,android,blackberry,Java,Android,Blackberry,如何在不使用HorizontalFieldManager或VerticalFieldManager以及不使用setMargin()的情况下,通过自定义位置的坐标将字段放置在管理器中: 非常感谢 试试这样的方法: public Manager getCustomManager() { Manager myCustomManager = new Manager(Manager.NO_HORIZONTAL_SCROLL|Manager.NO_HORIZONTAL_SCROLLBAR|M

如何在不使用HorizontalFieldManager或VerticalFieldManager以及不使用setMargin()的情况下,通过自定义位置的坐标将字段放置在管理器中:


非常感谢

试试这样的方法:

public Manager getCustomManager() {
        Manager myCustomManager = new Manager(Manager.NO_HORIZONTAL_SCROLL|Manager.NO_HORIZONTAL_SCROLLBAR|Manager.NO_VERTICAL_SCROLL|Manager.NO_VERTICAL_SCROLLBAR ) {
            protected void sublayout(int width, int height) {
                //Suppose we have to place two fields in our Manager
                if (getFieldCount() == 2) {
                    int
                    /** width and height values for the two fields */
                    w1, h1 , w2, h2 ,
                    /** position values for the two fields */
                    x1=5, y1=5, x2=10, y2=20;

                    // Get the first field added to the manager
                    Field f1 = getField(0);
                    h1 = f1.getHeight();
                    w1 = f1.getWidth();
                    // set the available width and height for the first field
                    layoutChild(f1, w1, h1);
                    // Set the position of the first field in the manager
                    setPositionChild(f1, x1, y1);

                    // Get the second field added to the manager
                    Field f2 = getField(1);
                    h2 = f2.getHeight();
                    w2 = f2.getWidth();
                    // set the available width and height for the second field
                    layoutChild(f2, w2, h2);
                    // Set the position of the second field in the manager
                    setPositionChild(f2, x2, y2);

                    setExtent(width, height);
                } else {
                    setExtent(0, 0);
                    // or  you can do something else in this case...
                }
            };
        };
        return myCustomManager;
    }

是的,使用BlackBerry,您可以通过循环管理器的子字段列表来实现这一点。使用setPositionChild(child,x,y)定位子字段。请在HeartBeat检查此问题
 public static class MyCustomManager extends Manager {
       public MyCustomManager () {
           super();
        }
       public void paint(Graphics g) {/**my painting*/super.paint(g);}
       protected void sublayout(int width, int height) {
        super.sublayout(PLOT, AUKST);

        setPositionChild(??,??)     //Something like this?
        setPosition(??, ??);        // or this? how?
        setExtent(??, ??);
        }

       }
public Manager getCustomManager() {
        Manager myCustomManager = new Manager(Manager.NO_HORIZONTAL_SCROLL|Manager.NO_HORIZONTAL_SCROLLBAR|Manager.NO_VERTICAL_SCROLL|Manager.NO_VERTICAL_SCROLLBAR ) {
            protected void sublayout(int width, int height) {
                //Suppose we have to place two fields in our Manager
                if (getFieldCount() == 2) {
                    int
                    /** width and height values for the two fields */
                    w1, h1 , w2, h2 ,
                    /** position values for the two fields */
                    x1=5, y1=5, x2=10, y2=20;

                    // Get the first field added to the manager
                    Field f1 = getField(0);
                    h1 = f1.getHeight();
                    w1 = f1.getWidth();
                    // set the available width and height for the first field
                    layoutChild(f1, w1, h1);
                    // Set the position of the first field in the manager
                    setPositionChild(f1, x1, y1);

                    // Get the second field added to the manager
                    Field f2 = getField(1);
                    h2 = f2.getHeight();
                    w2 = f2.getWidth();
                    // set the available width and height for the second field
                    layoutChild(f2, w2, h2);
                    // Set the position of the second field in the manager
                    setPositionChild(f2, x2, y2);

                    setExtent(width, height);
                } else {
                    setExtent(0, 0);
                    // or  you can do something else in this case...
                }
            };
        };
        return myCustomManager;
    }