Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带单行的BlackBerry RichTextField_Blackberry_Textfield_Blackberry Simulator - Fatal编程技术网

带单行的BlackBerry RichTextField

带单行的BlackBerry RichTextField,blackberry,textfield,blackberry-simulator,Blackberry,Textfield,Blackberry Simulator,我想为我的BB应用程序创建一个自定义列表字段。我在这方面取得了成功。我将在列表字段中绘制两个RichTextField,一个图像和一个RatingField 现在的问题是我只想在LIstField中显示RichTextField的单行。因此,如果有多行,那么它应该只显示一行 我想要它只是因为如果有超过一条线,我的拍击场就会重叠 见下图: 我正在使用以下代码创建它并设置值: rows = new TableRowManager[dealArray.length()];

我想为我的BB应用程序创建一个自定义列表字段。我在这方面取得了成功。我将在列表字段中绘制两个RichTextField,一个图像和一个RatingField

现在的问题是我只想在LIstField中显示RichTextField的单行。因此,如果有多行,那么它应该只显示一行

我想要它只是因为如果有超过一条线,我的拍击场就会重叠

见下图:

我正在使用以下代码创建它并设置值:

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);
现在,如果我想让description RichTextField只显示一行,该怎么办

请帮助我。

您需要使用RichTextField的方法来设置RichTextField的可用空间量

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;
            }
        }