单击复选框后,屏幕高度降低

时间:2013-04-11 05:46:49

标签: blackberry

大家好,               我在屏幕上工作,点击CheckBox后屏幕的高度减少(当更改监听器调用时)。 这是代码: -

public class IA_SearchScreen extends MainScreen implements FieldChangeListener 
{

    private CheckboxField ch1;
    private CheckboxField ch2;
    private CheckboxField ch3;

    private CheckboxField r1;
    private CheckboxField r2;
    private CheckboxField r3;

    private boolean togle_r1 = true;
    private boolean togle_r2;
    private boolean togle_r3;

    private AutoTextEditField iaDescriptionEditField;
    private AutoTextEditField streetEditField;
    private AutoTextEditField postCodeEditField ;
    private AutoTextEditField radiusEditField ;

    private Bitmap filterButton_F = Bitmap.getBitmapResource("filter_ focus.png");
    private Bitmap filterButton_N = Bitmap.getBitmapResource("filter_Unfocuss.png");
    private int temp_mgr_Height = 0;

    private StatusManager status_Manager;
    private ImageButton map_Button;
    private ImageButton favorite_Button;
    private ImageButton search_Button;

    private Calendar calendar;

    private LabelField _startDateLabelField;
    private LabelField _startTimeLabelField;

    private LabelField _endDateLabelField;
    private LabelField _endTimeLabelField;

    private String[] street_Array;
    private String[] postCode_Array;


    private String SearchString     = Global.EMPTY;
    private String DisruptionsType  = Global.EMPTY;
    private String Lat              = Global.EMPTY;
    private String Long             = Global.EMPTY;
    private String Radius           = Global.EMPTY;
    private String Severity         = Global.EMPTY;
    private String StartDate        = Global.EMPTY;
    private String EndDate          = Global.EMPTY;
    private String PostCode         = Global.EMPTY;
    private String StreetName       = Global.EMPTY;
    private String AllDates         = Global.EMPTY;


    private VerticalFieldManager _workSpace ; 

    public IA_SearchScreen()
    {
        super(Screen.USE_ALL_HEIGHT);

        _workSpace = (VerticalFieldManager)getMainManager();

        /**
         *  Initialize Screen Components
         * */



        iaDescriptionEditField = new AutoTextEditField("" , "", 500, EditField.NO_NEWLINE | EditField.NON_SPELLCHECKABLE)
        {
            protected void layout(int width, int height) 
            {
                super.layout(width, height);
                setExtent((Global.Display_Width - 40), getHeight());
            };
            protected void paint(Graphics graphics) 
            {
                graphics.setColor(Color.BLACK);

                super.paint(graphics);
            }
        };
        iaDescriptionEditField.setFont(Global.arialFont_Plain_16);

        SizedHFM _source0 = new SizedHFM(Global.Display_Width -30);
        _source0.setBorder(BorderFactory.createRoundedBorder(new XYEdges(3, 3, 3, 3), 0x867E42, Border.STYLE_FILLED), true);
        _source0.add(iaDescriptionEditField);


        HorizontalFieldManager hfm_0 = new HorizontalFieldManager()
        {
            protected void sublayout(int maxWidth, int maxHeight) 
            {
                super.setExtent(maxWidth, maxHeight);
                Field f = getField(0);
                layoutChild(f, getPreferredWidthOfChild(f) ,getPreferredHeightOfChild(f));

                setPositionChild(f, 10, 25);
                temp_mgr_Height = getPreferredHeightOfChild(f) +20;

                f = getField(1);
                layoutChild(f, getPreferredWidthOfChild(f) ,getPreferredHeightOfChild(f));
                //setPositionChild(f, Global.Display_Width -70, 25);
                setPositionChild(f, Global.Display_Width -55, 25);

                setExtent(maxWidth,temp_mgr_Height + 35);
            };  

            protected void paint(Graphics graphics) 
            {
                graphics.setColor(Color.BLACK);
                graphics.setFont(Global.arialFont_Bold_16);
                graphics.drawText("Search by Incident or Accident Description", 15, 5);

                graphics.drawRect(5, 1, getWidth()-10, getHeight()-2);
                super.paint(graphics);
            }
        };

        hfm_0.add(_source0);
        hfm_0.add(new LabelField());

        /**
         *  StreetEditField Manager START
         * */
        streetEditField = new AutoTextEditField("" , "", 500, EditField.NO_NEWLINE | EditField.NON_SPELLCHECKABLE)
        {
            protected void layout(int width, int height) 
            {
                super.layout(width, height);
                setExtent((Global.Display_Width - 40), getHeight());
            };
            protected void paint(Graphics graphics) 
            {
                graphics.setColor(Color.BLACK);

                super.paint(graphics);
            }
        };
        streetEditField.setFont(Global.arialFont_Plain_16);

        SizedHFM _source = new SizedHFM(Global.Display_Width - 65);
        _source.setBorder(BorderFactory.createRoundedBorder(new XYEdges(3, 3, 3, 3), 0x867E42, Border.STYLE_FILLED), true);
        _source.add(streetEditField);

        ImageButton btn_go_streetEditField = new ImageButton(filterButton_N , filterButton_F)
        {
            protected boolean navigationClick(int status, int time) {
                fieldChangeNotify(1);
                return true;
            }
        };

        btn_go_streetEditField.setChangeListener(new FieldChangeListener() 
        {
            public void fieldChanged(Field field, int context) 
            {
                street_Invoke();
            }
        });


        HorizontalFieldManager hfm_1 = new HorizontalFieldManager()
        {
            protected void sublayout(int maxWidth, int maxHeight) 
            {
                super.setExtent(maxWidth, maxHeight);
                Field f = getField(0);
                layoutChild(f, getPreferredWidthOfChild(f) ,getPreferredHeightOfChild(f));

                setPositionChild(f, 10, 25);
                temp_mgr_Height = getPreferredHeightOfChild(f) +20;

                f = getField(1);
                layoutChild(f, getPreferredWidthOfChild(f) ,getPreferredHeightOfChild(f));
                //setPositionChild(f, Global.Display_Width -70, 25);
                setPositionChild(f, Global.Display_Width -filterButton_N.getWidth()-10, 25);

                setExtent(maxWidth,temp_mgr_Height + 35);
            };  

            protected void paint(Graphics graphics) 
            {
                graphics.setColor(Color.BLACK);
                graphics.setFont(Global.arialFont_Plain_16);
                graphics.drawText("Street", 15, 5);

                graphics.drawRect(5, 1, getWidth()-10, getHeight()-2);
                super.paint(graphics);
            }
        };

        hfm_1.add(_source);
        hfm_1.add(btn_go_streetEditField);

        /**
         *  StreetEditField Manager END
         * */


        /**
         *  PostCodeEditField Manager START
         * */

        postCodeEditField = new AutoTextEditField("" , "", 500, EditField.NO_NEWLINE | EditField.NON_SPELLCHECKABLE)
        {
            protected void layout(int width, int height) 
            {
                super.layout(width, height);
                setExtent((Global.Display_Width - 40), getHeight());
            };
            protected void paint(Graphics graphics) 
            {
                graphics.setColor(Color.BLACK);

                super.paint(graphics);
            }
        };
        postCodeEditField.setFont(Global.arialFont_Plain_16);

        SizedHFM _source1 = new SizedHFM(Global.Display_Width -65);
        _source1.setBorder(BorderFactory.createRoundedBorder(new XYEdges(3, 3, 3, 3), 0x867E42, Border.STYLE_FILLED), true);
        _source1.add(postCodeEditField);

        ImageButton btn_go_postCodeEditField = new ImageButton(filterButton_N , filterButton_F)
        {
            protected boolean navigationClick(int status, int time) {

                fieldChangeNotify(1);       
                return true;
            }
        };

        btn_go_postCodeEditField.setChangeListener(new FieldChangeListener() 
        {
            public void fieldChanged(Field field, int context) 
            {
                postCode_Invoke();
            }
        });


        HorizontalFieldManager hfm_2 = new HorizontalFieldManager()
        {
            protected void sublayout(int maxWidth, int maxHeight) 
            {
                super.setExtent(maxWidth, maxHeight);
                Field f = getField(0);
                layoutChild(f, getPreferredWidthOfChild(f) ,getPreferredHeightOfChild(f));

                setPositionChild(f, 10, 25);
                temp_mgr_Height = getPreferredHeightOfChild(f) +20;

                f = getField(1);
                layoutChild(f, getPreferredWidthOfChild(f) ,getPreferredHeightOfChild(f));
                //setPositionChild(f, Global.Display_Width -70, 25);
                setPositionChild(f, Global.Display_Width - filterButton_N.getWidth()-10, 25);

                setExtent(maxWidth,temp_mgr_Height + 35);
            };  

            protected void paint(Graphics graphics) 
            {
                graphics.setColor(Color.BLACK);
                graphics.setFont(Global.arialFont_Plain_16);
                graphics.drawText("Post code", 15, 5);

                graphics.drawRect(5, 1, getWidth()-10, getHeight()-2);
                super.paint(graphics);
            }
        };

        hfm_2.add(_source1);
        hfm_2.add(btn_go_postCodeEditField);


        /**
         *  PostCodeEditField Manager END
         * */

        radiusEditField = new AutoTextEditField("" , "", 5, EditField.NO_NEWLINE |AutoTextEditField.FILTER_INTEGER )
        {
            protected void layout(int width, int height) 
            {
                super.layout(width, height);
                setExtent((Global.Display_Width - 40), getHeight());
            };
            protected void paint(Graphics graphics) 
            {
                graphics.setColor(Color.BLACK);

                super.paint(graphics);
            }
        };
        radiusEditField.setFont(Global.arialFont_Plain_16);

        SizedHFM _source3 = new SizedHFM(Global.Display_Width -30);
        _source3.setBorder(BorderFactory.createRoundedBorder(new XYEdges(3, 3, 3, 3), 0x867E42, Border.STYLE_FILLED), true);
        _source3.add(radiusEditField);


        HorizontalFieldManager hfm_3 = new HorizontalFieldManager()
        {
            protected void sublayout(int maxWidth, int maxHeight) 
            {
                super.setExtent(maxWidth, maxHeight);
                Field f = getField(0);
                layoutChild(f, getPreferredWidthOfChild(f) ,getPreferredHeightOfChild(f));

                setPositionChild(f, 10, 25);
                temp_mgr_Height = getPreferredHeightOfChild(f) +20;

                f = getField(1);
                layoutChild(f, getPreferredWidthOfChild(f) ,getPreferredHeightOfChild(f));
                //setPositionChild(f, Global.Display_Width -70, 25);
                setPositionChild(f, Global.Display_Width -55, 25);

                setExtent(maxWidth,temp_mgr_Height + 35);
            };  

            protected void paint(Graphics graphics) 
            {
                graphics.setColor(Color.BLACK);
                graphics.setFont(Global.arialFont_Bold_16);
                graphics.drawText("Radius (in Meters)", 15, 5);

                graphics.drawRect(5, 1, getWidth()-10, getHeight()-2);
                super.paint(graphics);
            }
        };

        hfm_3.add(_source3);
        hfm_3.add(new LabelField());


        /**
         *   Start Date & Time
         * */



        _startDateLabelField = new LabelField("")
        {

            protected void layout(int width, int height) {
                super.layout(150, 25);
                super.setExtent(150, 25);
            }

            public boolean isFocusable() {
                return true;
            }

        };



        _startTimeLabelField = new LabelField("")
        {
            protected void layout(int width, int height) {
                super.layout(150, 25);
                super.setExtent(150, 25);
            }

            public boolean isFocusable() {
                // TODO Auto-generated method stub
                return true;
            }
        };



        HorizontalFieldManager startDateNTimeManager = new HorizontalFieldManager()
        {

            protected void sublayout(int maxWidth, int maxHeight) 
            {
                super.setExtent(Global.Display_Width,/*temp_mgr_Height + 25*/ 70);
                Field f = getField(0);
                layoutChild(f, getPreferredWidthOfChild(f) ,getPreferredHeightOfChild(f));

                setPositionChild(f, 20, 30);
                temp_mgr_Height = getPreferredHeightOfChild(f) +20;

                f = getField(1);
                layoutChild(f, getPreferredWidthOfChild(f) ,getPreferredHeightOfChild(f));
                //setPositionChild(f, Global.Display_Width -70, 25);
                setPositionChild(f, Global.Display_Width -120, 30);

                setExtent(maxWidth,/*temp_mgr_Height + 25*/ 70);
            };  

            protected void paint(Graphics graphics) 
            {
                graphics.setColor(Color.BLACK);
                graphics.setFont(Global.arialFont_Bold_16);
                graphics.drawText("Start Date & Time", 10, 5);


                graphics.drawRect(9, 25, 141, 30);

                graphics.drawRect((Global.Display_Width - 151), 25, 141, 30);

                graphics.drawRect(5, 1, getWidth()-10, getHeight()-2);
                super.paint(graphics);
            }

        };

        startDateNTimeManager.add(_startDateLabelField);
        startDateNTimeManager.add(_startTimeLabelField);


        /**
         *   End Date & Time
         * */
        _endDateLabelField =  new LabelField("")
        {

            protected void layout(int width, int height) {
                super.layout(150, 25);
                super.setExtent(150, 25);
            }

            public boolean isFocusable() {
                return true;
            }

        };



        _endTimeLabelField = new LabelField("")
        {

            protected void layout(int width, int height) {
                super.layout(150, 25);
                super.setExtent(150, 25);
            }

            public boolean isFocusable() {
                // TODO Auto-generated method stub
                return true;
            }


        };

        _startDateLabelField.setFont(Global.arialFont_Plain_18);
        _startTimeLabelField.setFont(Global.arialFont_Plain_18);
        _endDateLabelField.setFont(Global.arialFont_Plain_18);
        _endTimeLabelField.setFont(Global.arialFont_Plain_18);


        HorizontalFieldManager endDateNTimeManager = new HorizontalFieldManager()
        {

            protected void sublayout(int maxWidth, int maxHeight) 
            {
                super.setExtent(Global.Display_Width,/*temp_mgr_Height + 25*/ 70);
                Field f = getField(0);
                layoutChild(f, getPreferredWidthOfChild(f) ,getPreferredHeightOfChild(f));

                setPositionChild(f, 20, 30);
                temp_mgr_Height = getPreferredHeightOfChild(f) +20;

                f = getField(1);
                layoutChild(f, getPreferredWidthOfChild(f) ,getPreferredHeightOfChild(f));
                //setPositionChild(f, Global.Display_Width -70, 25);
                setPositionChild(f, Global.Display_Width -120, 30);

                setExtent(Global.Display_Width,/*temp_mgr_Height + 25*/ 70);
            };  

            protected void paint(Graphics graphics) 
            {
                graphics.setColor(Color.BLACK);
                graphics.setFont(Global.arialFont_Bold_16);
                graphics.drawText("End Date & Time", 10, 5);


                graphics.drawRect(9, 25, 141, 30);

                graphics.drawRect((Global.Display_Width - 151), 25, 141, 30);

                graphics.drawRect(5, 1, getWidth()-10, getHeight()-2);
                super.paint(graphics);
            }

        };

        endDateNTimeManager.add(_endDateLabelField);
        endDateNTimeManager.add(_endTimeLabelField);



        /**
         *  Add Components to Screen
         * */
        LabelField searchByLocation = new LabelField("Search by Location")
        {
            protected void paint(Graphics graphics) 
            {
                graphics.setColor(Color.BLACK);
                super.paint(graphics);
            }
        };
        searchByLocation.setFont(Global.arialFont_Bold_18);


        insertSearchModeManager();
        _workSpace.add(hfm_0);

        searchByLocation.setMargin(5, 5, 5, 10);
        _workSpace.add(searchByLocation);

        _workSpace.add(hfm_1);
        _workSpace.add(hfm_2);
        _workSpace.add(hfm_3);


        LabelField selectStartDateHeader = new LabelField("Select start date & end dates to check incidents in the future");
        selectStartDateHeader.setFont(Global.arialFont_Bold_16);

        selectStartDateHeader.setMargin(5, 5, 5, 10);
        _workSpace.add(selectStartDateHeader);


        insertDateSelectionManager();

        startDateNTimeManager.setMargin(10, 0, 10, 0);
        _workSpace.add(startDateNTimeManager);
        _workSpace.add(endDateNTimeManager);


        ButtonField btn_go = new ButtonField("Go" ,FIELD_HCENTER)
        {
            protected boolean navigationClick(int status, int time) {
                fieldChangeNotify(1);
                return true;
            }
        };

        btn_go.setMargin(10, 0, 0, 10);
        _workSpace.add(btn_go);


//      add(_workSpace);

        btn_go.setChangeListener(new FieldChangeListener() 
        {
            public void fieldChanged(Field field, int context) 
            {
                invokeAISearch();
            }
        });


        /**
         *  Status Manager
         * */
        insertStatusManager();


        /**
         *  Very First time r1 = All days should be selected
         * */
        /*r1.setSelected(true);
        invokeDays_Calculatio();*/
    }



    protected void invokeAISearch() 
    {   }


    private String getAllDates() 
    {
        String dateString = Global.EMPTY;

        return dateString;
    }



    private String getStartDateTime() 
    {
        String startDateString = Global.EMPTY;
        return startDateString;
    }

    private String getEndDateTime() {
        String endDateString = Global.EMPTY;
        return endDateString;
    }



    private String getSeverity() {

        String sevString = Global.EMPTY;
        return sevString;
    }




    private void show_AI(final Vector v_temp)
    {
    }



    private void insertSearchModeManager() {

        ch1 = new CheckboxField("Severe", true)
        {
            protected void layout(int width, int height) {
                super.layout(getPreferredWidth(), height);
                super.setExtent(getPreferredWidth(), height);
            }
        };
        ch2 = new CheckboxField("Moderate", true)
        {
            protected void layout(int width, int height) {
                super.layout(getPreferredWidth(), height);
                super.setExtent(getPreferredWidth(), height);
            }
        };
        ch3 = new CheckboxField("Slight", true)
        {
            protected void layout(int width, int height) {
                super.layout(getPreferredWidth(), height);
                super.setExtent(getPreferredWidth(), height);
            }
        };

        ch1.setFont(Global.arialFont_Plain_16);
        ch2.setFont(Global.arialFont_Plain_16);
        ch3.setFont(Global.arialFont_Plain_16);


        HorizontalFieldManager dateSelectionManager = new HorizontalFieldManager()
        {
            protected void sublayout(int maxWidth, int maxHeight) 
            {
                super.sublayout(maxWidth, maxHeight);

                setExtent(360, 50);
            }

            protected void paint(Graphics graphics) 
            {
                graphics.setColor(Color.BLACK);
                graphics.drawRect(5, 0, getWidth()-10, getHeight());
                super.paint(graphics);
            }
        };

        ch1.setMargin(0, 0, 0, 10);
        ch2.setMargin(0, 0, 0, 20);
        ch3.setMargin(0, 0, 0, 20);

        dateSelectionManager.add(ch1);
        dateSelectionManager.add(ch2);
        dateSelectionManager.add(ch3);

        LabelField selectStartDateHeader = new LabelField("Search by Severity");
        selectStartDateHeader.setFont(Global.arialFont_Bold_16);

        selectStartDateHeader.setMargin(5, 5, 5, 10);
        _workSpace.add(selectStartDateHeader);
        _workSpace.add(dateSelectionManager);



    }



    private void insertDateSelectionManager() 
    {

        r1 = new CheckboxField( "All Dates" , true)
        {
            protected void layout(int width, int height) {
                super.layout(getPreferredWidth(), height);
            }
        }; 

        r2 = new CheckboxField("Tomorrow",false)
        {
            protected void layout(int width, int height) {
                super.layout(getPreferredWidth(), height);
            }
        };
        r3 = new CheckboxField("Next 7 days",false)
        {
            protected void layout(int width, int height) {
                super.layout(getPreferredWidth(), height);
            }
        };


        HorizontalFieldManager dateSelectionManager = new HorizontalFieldManager()
        {
            protected void sublayout(int maxWidth, int maxHeight) 
            {
                super.sublayout(Global.Display_Width, 50);

                setExtent(Global.Display_Width, 50);
            }

            protected void paint(Graphics graphics) 
            {
                graphics.setColor(Color.BLACK);
                graphics.drawRect(5, 0, getWidth()-10, getHeight());
                super.paint(graphics);
            }
        };


        r1.setFont(Global.arialFont_Plain_16);
        r2.setFont(Global.arialFont_Plain_16);
        r3.setFont(Global.arialFont_Plain_16);

        r1.setMargin(0, 0, 0, 20);
        r2.setMargin(0, 0, 0, 20);
        r3.setMargin(0, 0, 0, 20);

        dateSelectionManager.add(r1);
        dateSelectionManager.add(r2);
        dateSelectionManager.add(r3);



        add(dateSelectionManager);


        r1.setChangeListener(new FieldChangeListener() 
        {
            public void fieldChanged(Field field, int context) 
            {
                if ( nonProgrammaticChange(context) )
                {
                    invokeDays_Calculation(r1); 
                }
            }
        });


        r2.setChangeListener(new FieldChangeListener() 
        {
            public void fieldChanged(Field field, int context) 
            {
                if ( nonProgrammaticChange(context) )
                {
                    invokeDays_Calculation(r2);
                }
            }
        });

        r3.setChangeListener(new FieldChangeListener() 
        {
            public void fieldChanged(Field field, int context) 
            {
                if ( nonProgrammaticChange(context) )
                {
                    invokeDays_Calculation(r3); 
                }
            }
        });
    }


    private boolean nonProgrammaticChange (int context) {
        return (context & FieldChangeListener.PROGRAMMATIC) != FieldChangeListener.PROGRAMMATIC;
    }

    protected void invokeDays_Calculation(CheckboxField selectedField) 
    {
        r1.setChecked(false);
        r2.setChecked(false);
        r3.setChecked(false);

        if(selectedField.equals(r1))
        {
            togle_r1 = !togle_r1;

            if(togle_r1)
            {
                r1.setChecked(true);

                togle_r2 = false;
                togle_r3 = false;

                _startDateLabelField.setText("");
                _startTimeLabelField.setText("");
                _endDateLabelField.setText("");
                _endTimeLabelField.setText("");
            }
            else 
            {
                if(!togle_r1 && !togle_r2 && !togle_r3)
                {
                    Calendar todaysDate = Calendar.getInstance(); 
                    int tDayStr =  todaysDate.get(Calendar.DATE);
                    int tMonStr =  todaysDate.get(Calendar.MONTH);
                    int tYearStr =  todaysDate.get(Calendar.YEAR);


                    /**
                     * In Calendar class Month start form 0 thats why I incremented one time
                     * */
                    ++tMonStr;

                    /*System.out.println("t Date "+tDayStr);
                    System.out.println("t Month "+tMonStr);
                    System.out.println("t Year "+tYearStr);*/

                    String startDateStr = tDayStr+"/"+tMonStr+"/"+tYearStr;

                    _startDateLabelField.setText(startDateStr);
                    _startTimeLabelField.setText("00:00");
                    _endDateLabelField.setText(startDateStr);
                    _endTimeLabelField.setText("23:59");

                }
            }
        }

        if(selectedField.equals(r2))
        {
            togle_r2 = !togle_r2;

            if(togle_r2)
            {

                r2.setChecked(true);

                togle_r1 = false;
                togle_r3 = false;

                Calendar todaysDate = Calendar.getInstance(); 
                int tDayStr =  todaysDate.get(Calendar.DATE);
                int tMonStr =  todaysDate.get(Calendar.MONTH);
                int tYearStr =  todaysDate.get(Calendar.YEAR);


                ++tDayStr;
                /**
                 * In Calendar class Month start form 0 thats why I incremented one time
                 * */
                ++tMonStr;

                /*System.out.println("t Date "+tDayStr);
                System.out.println("t Month "+tMonStr);
                System.out.println("t Year "+tYearStr);*/

                String startDateStr = tDayStr+"/"+tMonStr+"/"+tYearStr;

                _startDateLabelField.setText(startDateStr);
                _startTimeLabelField.setText("00:00");
                _endDateLabelField.setText(startDateStr);
                _endTimeLabelField.setText("23:59");
            }
        }


        if(selectedField.equals(r3))
        {
            togle_r3 = !togle_r3;

            if(togle_r3)
            {
                r3.setChecked(true);

                togle_r1 = false;
                togle_r2 = false;

                Calendar todaysDate = Calendar.getInstance(); 
                int tDayStr =  todaysDate.get(Calendar.DATE);
                int tMonStr =  todaysDate.get(Calendar.MONTH);
                int tYearStr =  todaysDate.get(Calendar.YEAR);



                /**
                 * In Calendar class Month start form 0 thats why I incremented one time
                 * */
                ++tMonStr;

                /*System.out.println("t Date "+tDayStr);
                System.out.println("t Month "+tMonStr);
                System.out.println("t Year "+tYearStr);*/

                String startDateStr = tDayStr+"/"+tMonStr+"/"+tYearStr;

                _startDateLabelField.setText(startDateStr);
                _startTimeLabelField.setText("00:00");

                tDayStr += 7;
                startDateStr = tDayStr+"/"+tMonStr+"/"+tYearStr;

                _endDateLabelField.setText(startDateStr);
                _endTimeLabelField.setText("23:59");
            }
        }

    }


    public void fieldChanged(Field field, int context) {
        // TODO Auto-generated method stub

    }


    protected void street_Invoke() 
    {
    }

    protected void postCode_Invoke() {


    }

    void showStreetPopUp(final String[] street_Array)
    {

    }

    public void showCarParkingStreetPopUp(final String[] postCode_Array)
    {
    }

    public void updateStreetField(String strVal) 
    {


    }

    public void updatePostField(String strVal) {


    }


    public boolean onClose() 
    {
        setDirty(false);
        return super.onClose();
    }

    protected void sublayout(int width, int height) 
    {
        super.sublayout(Global.Display_Width, Global.Display_Height + 100);
        super.setExtent(Global.Display_Width, Global.Display_Height + 100);
    }

    protected void paint(Graphics graphics) 
    {
        // TODO Auto-generated method stub
        super.paint(graphics);
    }


}

注意:代码在5.0 OS中运行良好,但在6.0& 7.0它会产生问题。  请让我知道为什么我会遇到这个问题。

1 个答案:

答案 0 :(得分:1)

问题是你已经为OS 5.0上的特定设备制作了特定的应用,这显然是非触摸的。现在在Touch设备上,按钮和复选框的大小要大得多,而您却试图将它们限制为更小的尺寸。所以复选框通常会占用你所做的任何内容,但是当聚焦时,他们会尝试为自己腾出空间,这会干扰你的屏幕布局。删除复选框中的人为约束,您的直接问题可能会得到解决。

但是,此代码中存在许多问题,可能会在以后引发问题。

  1. 使用Screen.USE_ALL_HEIGHT不会影响整个显示。

  2. 你不必要地覆盖每一个领域以某种方式约束他们的身高。而你做错了。例如,在iaDescriptionEditField中,您已为布局提供了全宽,但随后限制了其大小。这将导致该字段未在末端绘制。

  3. 您拥有硬编码的宽度和高度 - 包括以像素为单位的字体,这会使您的应用在高像素密度设备(如粗体3)上看起来非常糟糕。

  4. 您正在覆盖Horizo​​ntalFieldManager,然后完全重新创建sublayout方法。最好只是扩展Manager类,因为您似乎没有使用Horizo​​ntalFieldManager的任何工具。

  5. 请记住,并非所有字段都会提供正确的getPreferredWidth / Height,您应该只使用这些方法在布局过程中进行估算。

  6. 我建议您在考虑到您需要定位的不同设备后重新考虑并重写整个代码。使用基于点的字体和测量而不是基于像素的测量。

    一切顺利。