为非触摸屏和触摸屏设计BlackBerry应用程序的差异

时间:2011-07-02 08:40:37

标签: blackberry

我已经开发了一个Blackberry应用程序并在Simulator(9800)上运行它现在我想要它也适用于非触摸设备。 问题是我在非触摸模拟器上测试即。 9780这两个组件缺失

请帮帮我。 下面是我的登录屏幕的代码。

public class JLoginScreen extends MyFramePageForLogin
{    
   public MyHttpConnectionClass myhttp=new MyHttpConnectionClass();
   MyParser mypar=new MyParser();
   private LabelField lblalreadymember,lblnotamember;//cotegories for exixtence
   private LabelField lbllogin,lblpassword,rmtemp1,rmtemp2,rmtemp3,rmtemp4;   
   private CustomRoundBorderTextBoxField rblogin;
   private CustomRoundBorderPasswordField rbpassword;
   private LabelField linkforgetpwd; 
   private CustomButtonField cbflogin,cbfregisternow;
   CheckboxField checkRemeberMe;
   CheckboxField cbField;
   int mCheckBoxesCount = 5; 
   public static String membername,person_fname,person_lname,address,
   contactperson,mail,phone,mobile,membertitle,memberid;
   private GridFieldManager gfmlogin;  
   private GridFieldManager gfmtxt;  
   private GridFieldManager hfmforgetlogin;
   Font fontlistfield;  
   MyConnectionClass my_con=new MyConnectionClass();
   MyFont myfont=new MyFont();  
   private int isVal=0;

   public JLoginScreen()
   {      
      lblalreadymember=new LabelField("Already A Member ?")
      {
         public void paint(Graphics g)
         {
            //g.setColor(0x585858);
            super.paint(g);
         }
      };
      lblalreadymember.setFont(myfont.headfont);

      lblalreadymember.setMargin(10,0,0, 10);
      //Login 
      lbllogin=new LabelField("Login",NON_FOCUSABLE)
      {
         public void paint(Graphics g)
         {
            g.setColor(0x585858);
            super.paint(g);
         }
      };
      lbllogin.setFont(myfont.boldfont);
      lbllogin.setMargin(0,0,0,10);

      lblpassword=new LabelField("Password")
      {
         public void paint(Graphics g)
         {
            g.setColor(0x585858);
            super.paint(g);
         }
      };
      lblpassword.setFont(myfont.boldfont);

      linkforgetpwd=new LabelField("Forget Password?")
      {
         public void paint(Graphics g)
         {
            g.setColor(0x585858);
            super.paint(g);
         }
      };
      linkforgetpwd.setPadding(0,0, 0,5);
      linkforgetpwd.setFont(myfont.contentdata);  

      rblogin=new CustomRoundBorderTextBoxField(200,25,3); 
      rblogin.setFont(myfont.contentdata);

      rbpassword=new CustomRoundBorderPasswordField(200,25,3);
      rbpassword.setFont(myfont.loginpassword);
      //rbpassword.setPadding(5,0, 0,2);

      rmtemp1=new LabelField("")
      {
         public void paint(Graphics g)
         {
            g.setColor(0x585858);
            super.paint(g);
         }
      };
      rmtemp2=new LabelField("")
      {
         public void paint(Graphics g)
         {
            g.setColor(0x585858);
            super.paint(g);
         }
      };
      rmtemp3=new LabelField("")
      {
         public void paint(Graphics g)
         {
            g.setColor(0x585858);
            super.paint(g);
         }
      };
      rmtemp4=new LabelField("")
      {
         public void paint(Graphics g)
         {
            g.setColor(0x585858);
            super.paint(g);
         }
      };
      checkRemeberMe = new CheckboxField("Remember Me", false)
      {
         public void paint(Graphics g)
         {
            g.setColor(0x585858);
            super.paint(g);
         }
      };
      checkRemeberMe.setPadding(0,0, 0,10);
      checkRemeberMe.setFont(MyFont.contentdata);
      //CustomButtonField For Login
      cbflogin=new CustomButtonField("            Login       ", Color.BLACK);  

      cbflogin.setPadding(0,0, 0, 200);
      cbflogin.setFont(MyFont.contentdata);
      cbflogin.setChangeListener(new FieldChangeListener() 
      {
         public void fieldChanged(Field field, int context) 
         {           
            try
            {
               String url="http://www.jewelvicinity.com/pushmobile.aspx?cmdtype=LOGIN&email="+rblogin.getText()+"&pwd="+rbpassword.getText()+"";
               String response =MyHttpConnectionClass.getPage(url);
               String isActive =mypar.getWIGIBarcodeInfo(response,"<MemberActive>","</MemberActive>",14);
               membername =mypar.getWIGIBarcodeInfo(response,"<MemberName>","</MemberName>",12);
               person_fname =mypar.getWIGIBarcodeInfo(response,"<MemberPersonFName>","</MemberPersonFName>",19);
               person_lname =mypar.getWIGIBarcodeInfo(response,"<MemberPersonLName>","</MemberPersonLName>",19);
               membertitle=mypar.getWIGIBarcodeInfo(response,"<MemberTitle>","</MemberTitle>",13);
               memberid=mypar.getWIGIBarcodeInfo(response,"<MemberID>","</MemberID>",10);

               address =mypar.getWIGIBarcodeInfo(response,"<MemberAdd1>","</MemberAdd1>",12);
               phone =mypar.getWIGIBarcodeInfo(response,"<MemberPhone1>","</MemberPhone1>",14);
               mobile =mypar.getWIGIBarcodeInfo(response,"<MemberMobile>","</MemberMobile>",14);
               mail =mypar.getWIGIBarcodeInfo(response,"<MemberEMail>","</MemberEMail>",13);
               //boolean isActive=Boolean.isActive;
               //Dialog.alert(""+response);
               //Dialog.alert(""+memberid);

               if(isVal==0)
               {                
                  if(isActive.equalsIgnoreCase("true"))                 
                  {                  
                     UiApplication.getUiApplication().pushScreen(new JSearchDiamondPage());                     
                     rblogin.setText("");
                     rbpassword.setText("");
                     Setting.setMemberID(memberid);

                  } 
                  else
                  {
                     Dialog.alert("Enter correct user name and Password");
                     rblogin.setText("");
                     rbpassword.setText("");
                     rblogin.setFocus();           
                  }
               }
            }
            catch(Exception ex)
            {
               Dialog.alert(""+ex);
            }
         }
      });

      hfmforgetlogin =new GridFieldManager(3,2,1|GridFieldManager.NON_FOCUSABLE);
      hfmforgetlogin.setPadding(0, 0, 0, 0);
      hfmforgetlogin.setColumnProperty(0, GridFieldManager.FIXED_SIZE, 160);
      hfmforgetlogin.setColumnProperty(1, GridFieldManager.FIXED_SIZE, 220);
      hfmforgetlogin.add(rmtemp1);
      hfmforgetlogin.add(rmtemp2);
      hfmforgetlogin.add(checkRemeberMe,Field.NON_FOCUSABLE);     
      hfmforgetlogin.add(linkforgetpwd);
      hfmforgetlogin.add(rmtemp3);
      hfmforgetlogin.add(rmtemp4);

      //hfmforgetlogin.add(cbflogin);
      //Grid Field Manager
      gfmlogin=new GridFieldManager(2,1,1|GridFieldManager.NON_FOCUSABLE);
      gfmlogin.setRowProperty(0,GridFieldManager.FIXED_SIZE,30);
      gfmlogin.setRowProperty(1,GridFieldManager.FIXED_SIZE,10);
      gfmlogin.setPadding(10,0, 0, 10);
      gfmlogin.setFont(myfont.contentdata);
      //gfmlogin.nextFocus(2,1);
      gfmlogin.add(lbllogin,GridFieldManager.FIELD_LEFT);
      gfmlogin.add(lblpassword);

      gfmtxt=new GridFieldManager(2,1,1|GridFieldManager.FOCUSABLE);
      gfmtxt.setPadding(10,0, 0, 10);
      gfmtxt.setFont(myfont.contentdata);
      //gfmtxt.setFocus(67,97,);
      gfmtxt.nextFocus(0,0);
      gfmtxt.add(rblogin,FOCUSABLE);
      gfmtxt.add(rbpassword,FOCUSABLE);
      HorizontalFieldManager hfm=new HorizontalFieldManager();
      hfm.setPadding(0,0,0,0);
      hfm.add(gfmlogin); 
      hfm.add(gfmtxt); 
      MyFramePageForLogin.contentarea.add(lblalreadymember);
      MyFramePageForLogin.contentarea.add(hfm);
      MyFramePageForLogin.contentarea.add(hfmforgetlogin);     
      MyFramePageForLogin.contentarea.add(cbflogin);

      /********************************************************/
      //Adding line as image     
      BitmapField lineimg = new BitmapField(Bitmap.getBitmapResource("line.png"), BitmapField.LEFT);
      lineimg.setPadding(20, 30, 10, 10);
      MyFramePageForLogin.contentarea.add(lineimg);
      /**************END of adding Line***********************/

      lblnotamember=new LabelField("Not a Member ?")
      {
         public void paint(Graphics g)
         {
            //g.setColor(0x585858);
            super.paint(g);
         }
      };    
      //lblnotamember.setPadding(Display.getHeight()/2+100,0,0,10);
      lblnotamember.setFont(myfont.headfont);
      lblnotamember.setPadding(10,10,10,10);

      MyFramePageForLogin.contentarea.add(lblnotamember);//End       

      /******Adding Register Button**************/
      /* ButtonField bf=new ButtonField("HEllo");
         contentarea.add(bf);*/
      cbfregisternow=new CustomButtonField("       Register Now", Color.CYAN);
      cbfregisternow.setPadding(5,10,10,200);
      cbfregisternow.setFont(MyFont.contentdata);
      cbfregisternow.setChangeListener(new FieldChangeListener() 
      {
         public void fieldChanged(Field field, int context) 
         {           
            //Dialog.alert("Mobile:"+umobile+",Created On:"+ucreated_on+",Active:"+uactive+",Paid"+umember_paid+",Appr"+umember_appr);
            UiApplication.getUiApplication().pushScreen(new JNewRegistrationPage());
            //UiApplication.getUiApplication().pushScreen(new JVendorDetailsPage(name1,person,address,phone,mobile,mail));          
         }
      });
      MyFramePageForLogin.contentarea.add(cbfregisternow);     
      rblogin.setFocus();
      //setFocus();
   }
   protected boolean onSavePrompt() 
   {
      return true;
   }
}

以上代码2非触摸屏上未显示的组件

  1. rblogin
  2. rbpassword
  3. 这是自定义文本字段。

1 个答案:

答案 0 :(得分:1)

我看到的组件rblogin和rbpassword是定制的(ref:className - CustomRoundBorderTextBoxField)

以下内容可能会导致您遇到的问题:

  • CustomRoundBorderTextBoxField扩展的类可能在OS 5.0中不可用(9780附带两个OS版本5.0和6.0,具体取决于型号)

  • 由于屏幕大小,字段可能会放错位置记住9800是360x480而9780是小尺寸

  • 有人可能会忘记将其添加到屏幕上:)

如果问题仍然无法解决,请发表评论

由于 Dheeraj Jami