2011-08-16 7 views
0

私はブラックベリーが初めてです。これは私の最初の質問です。私はこれに対して複数のtextbox.iが必要なサンプルアプリケーションを作成しています。複数行のテキストボックス、ブラックベリーのボーダー付き

VerticalFieldManager vfm =new VerticalFieldManager(Manager.VERTICAL_SCROLL) 
      { 
       public void paint(Graphics g) 
          { 

          g.drawRoundRect(0, 0,getWidth(), getHeight(),12,12); 
         super.paint(g); 
        } 
       public void sublayout(int width, int height) 
           { 
         if (managerWidth == 0) { 
         managerWidth = width; 
         } 
         if (managerHeight == 0) { 
         managerHeight = height; 
         } 
         super.sublayout(managerWidth, managerHeight); 
         setExtent(managerWidth,managerHeight); 
        } 

      }; 

       editField = new EditField(){ 
       public void paint(Graphics g) { 
       getManager().invalidate(); 
       super.paint(g); 
       } 
      }; 

      vfm.add(editField); 
           vfm.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE)); 
      add(vfm); 

テキストフィールドheight.Theのテキストは、私がproblem.Pleaseが私を助けることを修正border.Howを横切っているよりも大きい場合、テキストは、フィールドの高さよりも小さい場合には、正常に動作します。

+0

マルチラインテキストボックスとはどういう意味ですか? czをデフォルトで使用すると、複数の行を受け入れるeditFieldを使うことができます –

答えて

0

独自のカスタムフィールドを実装する必要があります。

マニュアルは、ここで見つけることができます:"Create a custom field"

0

あなたはブラックベリーのAPIおよび使用からEditFieldを使用することができます。

yourEditField.setBorder(yourBorder); 

あなたはその後、国境での編集フィールドを持っていると

0
数行を受け入れるだろう
package nativeapp; 
import net.rim.device.api.system.Bitmap; 
import net.rim.device.api.system.Display; 
import net.rim.device.api.ui.Color; 
import net.rim.device.api.ui.Field; 
import net.rim.device.api.ui.FieldChangeListener; 
import net.rim.device.api.ui.Graphics; 
import net.rim.device.api.ui.UiApplication; 
import net.rim.device.api.ui.XYEdges; 
import net.rim.device.api.ui.component.BitmapField; 
import net.rim.device.api.ui.component.ButtonField; 
import net.rim.device.api.ui.component.CheckboxField; 
import net.rim.device.api.ui.component.Dialog; 
import net.rim.device.api.ui.component.LabelField; 
import net.rim.device.api.ui.container.HorizontalFieldManager; 
import net.rim.device.api.ui.container.MainScreen; 
import net.rim.device.api.ui.container.VerticalFieldManager; 
import net.rim.device.api.ui.decor.Background; 
import net.rim.device.api.ui.decor.BackgroundFactory; 
import net.rim.device.api.ui.decor.Border; 
import net.rim.device.api.ui.decor.BorderFactory; 

public class LoginScreen extends MainScreen { 

    /** 
    * Login page 
    */ 

    private ButtonField btnLogin; 
    //private EditField txtUserID; 
    CustomTextBox txtUserID; 
    CustomTextBox txtPassword; 
    // private PasswordEditField txtPassword; 
    private CheckboxField Chkbox; 
    private LabelField RememberMe; 

    public LoginScreen() { 
     super(NO_VERTICAL_SCROLL); 

     txtUserID = new CustomTextBox() { 

      protected void paint(Graphics g) { 
       // Border roundedBorder = BorderFactory 
       // .createRoundedBorder(new XYEdges(9, 9, 9, 9), 
       // Color.GRAY, Border.STYLE_SOLID); 
       // setBorder(roundedBorder); 
       // setBackground(BackgroundFactory 
       // .createSolidBackground(Color.WHITE)); 

       if (getText().length() == 0) { 
        g.setColor(Color.GRAY); 
        g.drawText("UserName", 0, 0); 

       } 
       g.setColor(Color.BLACK); 
       //g.drawRect(0, 0, (int) (Display.getWidth()/1.5), 
         //txtUserID.getHeight()/* (int)(Display.getHeight()/9) */); 
       super.paint(g); 
      } 
     }; 

     txtPassword = new CustomTextBox() { 
      protected void paint(Graphics g) { 
       Border roundedBorder = BorderFactory 
         .createRoundedBorder(new XYEdges(9, 9, 9, 9), 
           Color.GRAY, Border.STYLE_SOLID); 
       setBorder(roundedBorder); 
       setBackground(BackgroundFactory 
         .createSolidBackground(Color.WHITE)); 
       if (getText().length() == 0) { 
        g.setColor(Color.GRAY); 
        g.drawText("txtPassword", 0, 0); 
       } 
       g.setColor(Color.BLACK); 
       super.paint(g); 
      } 
     }; 

     // btnLogin = new ButtonField("SignIn"); 
     btnLogin = new ButtonField("Sign In", Field.FIELD_HCENTER); 

     Chkbox = new CheckboxField(); 
     // Chkbox.setMargin(0, 0, 0, 30); 
     RememberMe = new LabelField("Remember Me"); 
     // RememberMe.setMargin(10, 0, 0, 0); 

     FieldChangeListener login = new FieldChangeListener() { 

      public void fieldChanged(Field field, int context) { 
       String uname = txtUserID.getText().toString().trim(); 
       String pword = txtPassword.getText().toString().trim(); 
       if (!uname.equalsIgnoreCase("") 
         && !uname.equalsIgnoreCase(null) 
         && !pword.equalsIgnoreCase("") 
         && !pword.equalsIgnoreCase(null)) { 
        boolean lgnStatus = (new httpClient()).loginStatus(uname, 
          pword, DataURL.smartURLloginchk); 
        if (lgnStatus) { 
         PersistentsStore ps = new PersistentsStore(); 
         ps.setObject(DataURL.UserName, uname); 
         ps.setObject(DataURL.PassWord, pword); 
         UiApplication.getUiApplication().popScreen(
           LoginScreen.this); 
         UiApplication.getUiApplication().pushScreen(
           new WelcomeScreen()); 
        } else { 
         Dialog.inform("Invalid UserID or Password"); 
        } 

       } else { 
        Dialog.inform("UserID and Password shouldnot be Empty"); 
       } 

      } 
     }; 

     FieldChangeListener cancel = new FieldChangeListener() { 

      public void fieldChanged(Field field, int context) { 

      } 
     }; 

     btnLogin.setChangeListener(login); 
     // btnCancel.setChangeListener(cancel); 
     setLoginScreen(); 
    } 

    private void setLoginScreen() { 

     VerticalFieldManager vfmForCenterDisplay = new VerticalFieldManager(
       Field.FIELD_HCENTER | Field.FIELD_VCENTER | Field.USE_ALL_WIDTH 
         | Field.USE_ALL_HEIGHT) { 
      protected void sublayout(int maxWidth, int maxHeight) { 
       super.sublayout(maxWidth, maxHeight); 

      } 
     }; 

     Background background = BackgroundFactory.createBitmapBackground(Bitmap 
       .getBitmapResource("bground.png")); 
     vfmForCenterDisplay.setBackground(background); 

     int topSpace = (Display.getHeight()/4); 
     vfmForCenterDisplay.setPadding(topSpace, 0, 0, 0); 

     VerticalFieldManager vfmBasicInfoWithBorder1 = new VerticalFieldManager(
       FIELD_HCENTER | FIELD_VCENTER) { 
      protected void sublayout(int maxWidth, int maxHeight) { 
       super.sublayout(250, 95); 
      } 
     }; 

     BitmapField bitmapField = new BitmapField(
       Bitmap.getBitmapResource("loginbg_01.png")) { 
      protected void layout(int width, int height) { 
       setExtent(250, 95); 
      } 
     }; 

     vfmBasicInfoWithBorder1.add(bitmapField); 

     VerticalFieldManager vfmBasicInfoWithBorder2 = new VerticalFieldManager(
       FIELD_HCENTER | FIELD_VCENTER) { 
      protected void sublayout(int maxWidth, int maxHeight) { 
       super.sublayout(250, 95); 
      } 

     }; 
     vfmBasicInfoWithBorder2.setBackground(BackgroundFactory 
       .createBitmapBackground(Bitmap 
         .getBitmapResource("loginbg_02.jpg"))); 

     VerticalFieldManager vfmBasicInfoWithBorder3 = new VerticalFieldManager(
       FIELD_HCENTER | FIELD_VCENTER) { 
      protected void sublayout(int maxWidth, int maxHeight) { 
       super.sublayout(250, 95); 
       setExtent(250, 95); 
      } 
     }; 

     vfmBasicInfoWithBorder3.setBackground(BackgroundFactory 
       .createBitmapBackground(Bitmap 
         .getBitmapResource("loginbg_03.png"))); 
     vfmBasicInfoWithBorder3.add(btnLogin); 
     // btnLogin.setMargin(0, 0, 0, 0); 

     // HorizontalFieldManager hfm1 = new HorizontalFieldManager(
     // Field.FIELD_HCENTER); 

     HorizontalFieldManager hfm2 = new HorizontalFieldManager(
       Field.FIELD_VCENTER); 
     hfm2.add(txtUserID); 
     // txtUserID.setMargin(0, 0, 0, 0); 

     HorizontalFieldManager hfm3 = new HorizontalFieldManager(FIELD_HCENTER 
       & FIELD_VCENTER); 
     hfm3.add(txtPassword); 
     // txtPassword.setMargin(0, 0, 0, 10); 

     HorizontalFieldManager hfm4 = new HorizontalFieldManager(
       Field.FIELD_HCENTER); 
     hfm4.add(Chkbox); 
     Chkbox.setMargin(0, 0, 0, 10); 
     hfm4.add(RememberMe); 
     RememberMe.setMargin(0, 0, 0, 10); 

     // HorizontalFieldManager hfm5 = new 
     // HorizontalFieldManager(FIELD_HCENTER 
     // & FIELD_VCENTER) { 
     // protected void sublayout(int maxWidth, int maxHeight) { 
     // super.sublayout(250, 95); 
     // } 
     // }; 
     // hfm5.add(btnLogin); 
     // btnLogin.setMargin(0, 0, 0, 0); 
     // hfm5.add(btnCancel); 
     // hfm5.setPadding(new XYEdges(0, 0, 0, ((250 - (70 + 75))/2))); 

     // btnCancel.setMargin(0, 0, 0, 15); 

     // vfmBasicInfoWithBorder1.add(hfm1); 
     vfmBasicInfoWithBorder2.add(hfm2); 
     vfmBasicInfoWithBorder2.add(hfm3); 
     vfmBasicInfoWithBorder3.add(hfm4); 
     // vfmBasicInfoWithBorder3.add(hfm5); 

     vfmForCenterDisplay.add(vfmBasicInfoWithBorder1); 
     vfmForCenterDisplay.add(vfmBasicInfoWithBorder2); 
     vfmForCenterDisplay.add(vfmBasicInfoWithBorder3); 
     add(vfmForCenterDisplay); 
    } 

}