2012-12-19 1 views
0

내 BB 앱에 맞춤 ListField를 만들고 싶습니다. 나는 그것에 성공했다. 두 개의 RichTextField, 하나의 Image 및 OneFieldField를 listField에 그려 보겠습니다.BlackBerry RichTextField (단일 줄 포함)

이제 문제는 LIstField에서 RichTextField의 한 줄만 표시하려고합니다. 그래서 하나 이상의 라인이 있다면 하나만 표시해야합니다.

내 ratting 필드가 겹치기 때문에 원하는 것은 한 줄 이상이면됩니다.

이미지 아래 참조 :

enter image description here

내가 그것을 생성하고 설정 값을 코드 아래 사용하고 있습니다 :

rows = new TableRowManager[dealArray.length()]; 

     rating2 = new RatingField(Bitmap.getBitmapResource("yellow_star.png") 
       , Bitmap.getBitmapResource("white_star.png") 
       , Bitmap.getBitmapResource("yellow_star.png") 
       , Bitmap.getBitmapResource("white_star.png") 
       , 8, 5, Field.FIELD_HCENTER); 
     try{ 
      System.out.println("================== = = ==HERE IT IS COMES"); 

     for(int i=0;i<dealArray.length();i++){ 
      // create a table row manager 
      rows[i] = new TableRowManager(); 
      // set the menu item name 
      EncodedImage encoded_img=EncodedImage.getEncodedImageResource("no_photo.png"); 
      byte[] data=encoded_img.getData(); 
      Bitmap bitmap=Bitmap.createBitmapFromBytes(data, 0, data.length,1);//Here we get the Image; 
      Bitmap scaleBitmap=new Bitmap(100,100);//Now we are scaling that image; 
      bitmap.scaleInto(scaleBitmap, Bitmap.FILTER_LANCZOS); 


      rows[i].add(new BitmapField(scaleBitmap)); 

      rows[i].add(new RichTextField(dealArray.getJSONObject(i).getString("DealName"), DrawStyle.ELLIPSIS)); 

      rows[i].add(new RichTextField(dealArray.getJSONObject(i).getString("DealDescription"), TextField.NO_NEWLINE)); 

      rows[i].add(new RatingField(Bitmap.getBitmapResource("yellow_star.png") 
        , Bitmap.getBitmapResource("white_star.png") 
        , Bitmap.getBitmapResource("yellow_star.png") 
        , Bitmap.getBitmapResource("white_star.png") 
        , Integer.parseInt(dealArray.getJSONObject(i).getString("DealTotalStamp")) 
        , Integer.parseInt(dealArray.getJSONObject(i).getString("StampCompletionOnDeal")) 
        , Field.FIELD_HCENTER)); 
      // create a table row manager 

     } 
     }catch(Exception e){ 
      e.printStackTrace(); 
     } 

     System.out.println("HELLOOOOoo oo ooo"); 

     vfm.addAll(rows); 

을 그리고 drawListRow에 그릴, 내가 코드 아래 사용

private class TableRowManager extends Manager{ 
      public TableRowManager(){ 
       super(0); 
      } 
      public void drawRow(Graphics g, int x, int y, int width, int height){ 
       // Arrange the cell fields within this row manager. 
       layout(width, height); 

       // Place this row manager within its enclosing list. 
       setPosition(x, y); 

       // Apply a translating/clipping transformation to the graphics 
       // context so that this row paints in the right area. 
       //g.pushRegion(getExtent()); 

       // Paint this manager's controlled fields. 
       subpaint(g); 

       g.setColor(0x00000000); 
       // g.drawLine(0, 0, getPreferredWidth(), 0); 

       // Restore the graphics context. 
       g.popContext(); 
      } 

      protected void sublayout(int width, int height) { 
       // TODO Auto-generated method stub 
       int preferredWidth = getPreferredWidth(); 
       int preferredHeight = getPreferredHeight(); 
       // for deal image 


       //SBitmapField bmp = new BitmapField(Bitmap.getBitmapResource("")); 
       Field field = getField(0); 
       layoutChild(field, 100, 100); 
       setPositionChild(field, 5, 5); 

       // for deal name 
       field = getField(1); 
       layoutChild(field, preferredWidth - 100, 0); 
       setPositionChild(field, 110, 0); 

       // for deal Description 
       field = getField(2); 
       layoutChild(field, preferredWidth, 5); 
       setPositionChild(field,110 , 35); 

       // for Deal stamp 
       field = getField(3); 
       layoutChild(field, preferredWidth, 50); 
       setPositionChild(field, 110, 65); 


       setExtent(preferredWidth, 110); 
      } 
      public int getPreferredWidth() 
      { 
       return Graphics.getScreenWidth(); 
      } 

      // The preferred height of a row is the "row height" as defined in the 
      // enclosing list. 
      public int getPreferredHeight() 
      { 
       return 30; 
      } 
     } 

이제 RichTextField 설명을 jus에서 원한다면 어떻게해야합니까? t 한 줄?

도와주세요.

답변

0

layout RichTextField 메서드를 사용하여 사용 가능한 공간의 크기를 RichTextField으로 설정해야합니다.