2013-04-11 28 views
0

大家好,我在屏幕上工作,屏幕高度减少后单击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的操作系统工作正常,但在6.0 & 7.0它创造的问题。 请让我知道为什么我得到这个问题。

+0

请访问[本站](http://sscce.org/)。绝对没有必要在这里发布这么多的代码。 – Nate 2013-04-11 09:53:28

+0

hello @Nate ..我会照顾,你能告诉我为什么我的屏幕得到减少后,每次点击dateSelection管理器,在insertDateSelectionManager()方法,当我评论setchangelistenr它工作正常.. – 2013-04-11 10:56:23

回答

1

问题在于,您已经针对OS 5.0上的某个特定设备制定了特定的应用程序,该应用程序显然没有触摸。现在在触控设备上,按钮和复选框的尺寸要大得多,而您试图将它们限制为更小的尺寸。所以复选框通常会采取你已经完成的任何事情,但是当它们集中时,它们会尝试为自己腾出空间,这会干扰你的屏幕布局。删除复选框中的人工约束,您的直接问题可能会得到解决。

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

  1. 使用Screen.USE_ALL_HEIGHT不会占用整个显示屏。

  2. 您不必要地覆盖每个领域,以某种方式限制他们的身高。你做错了。例如,在iaDescriptionEditField中,您已为布局给出了完整宽度,但随后限制了其大小。这将导致该字段在末尾处未被绘制。

  3. 你硬编码的宽度和高度 - 包括以像素为单位的字体,这将使你的应用程序看起来很糟糕的高像素密度的设备,如大胆3.

  4. 要覆盖一个Horizo​​ntalFieldManager然后完全重建子布局方法。最好只扩展Manager类,因为您似乎没有使用任何Horizo​​ntalFieldManager工具。

  5. 请记住,并非所有字段都会给出正确的getPreferredWidth/Height,并且您应该只使用这些方法在布局期间进行估计。

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

一切顺利。

+0

@adwin感谢您的答复据我所知,罪魁祸首部分是r1,r2,r3 setchangelistener部分..当我评论代码时屏幕可能不会减少,并且每件事情都可以正常工作,但根据应用程序的要求,一次只能选择一个复选框..我必须禁用其他 – 2013-04-12 05:55:21

+0

如果我不使用nonProgrammaticChange()..然后我得到堆栈溢出异常..有没有其他方法来解决问题 – 2013-04-12 08:51:36

+0

@Mario你的setChangeListeners做了很多事情包括检查/取消选中和设置标签字段。试着通过评论来找出代码的哪个部分正在做这件事。 – adwiv 2013-04-12 09:48:56