1

嗨,朋友,我如何在一个屏幕上显示黑莓中的几个数据。例如:


current Date------------value.
Name------------------- value.
roll--------------------value.
email-id----------------value.
phone-no----------------value.
pass--------------------value.
class-------------------value.
sex---------------------value.
college-----------------value.
city--------------------value.
state-------------------value.
pin code----------------value.
country-----------------value.
public LabelField lbSr, lbDate, lbAllo, lbMob, lbDetail, lbRemark, lbSlaDate, lbEmail, lbStatus, lbspace;
public LabelField lb1Sr, lb1Date, lb1Allo, lb1Mob, lb1Detail, lb1Remark, lb1SlaDate, lb1Email, lb1Status;
public JustifiedHorizontalFieldManager jhfm1,jhfm2,jhfm3,jhfm4,jhfm5,jhfm6,jhfm7,jhfm8,jhfm9;
VerticalFieldManager vfm=new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL);

lb1Sr = new LabelField("SRNo         :");
lb1Sr.setColor(Color.BLACK);

lbSr = new LabelField(strSerno);
lbSr.setColor(Color.BLACK);

lb1Date = new LabelField("SRDate      :");
lb1Date.setColor(Color.BLACK);

lbDate = new LabelField(strDate);
lbDate.setColor(Color.BLACK);

lb1Allo = new LabelField("AllocDate   :");
lb1Allo.setColor(Color.BLACK);

lbAllo = new LabelField(strAllo);
lbAllo.setColor(Color.BLACK);

lb1Mob = new LabelField("MobNo       :");
lb1Mob.setColor(Color.BLACK);

lbMob = new LabelField(strMob);
lbMob.setColor(Color.BLACK);

lb1Detail = new LabelField("SRDetails   :");
lb1Detail.setColor(Color.BLACK);

lbDetail = new LabelField(strDetail);
lbDetail.setColor(Color.BLACK);

lb1Remark = new LabelField("Remarks    :");
lb1Remark.setColor(Color.BLACK);

lbRemark = new LabelField(strRemark);
lbRemark.setColor(Color.BLACK);

lb1SlaDate = new LabelField("SLADate :");
lb1SlaDate.setColor(Color.BLACK);

lbSlaDate = new LabelField(strSldate);
lbSlaDate.setColor(Color.BLACK);

lb1Email = new LabelField("Email :");
lb1Email.setColor(Color.BLACK);

lbEmail = new LabelField(strEmail);
lbEmail.setColor(Color.BLACK);

lb1Status = new LabelField("Status :");
lb1Status.setColor(Color.BLACK);

lbStatus = new LabelField(strStatus);
lbStatus.setColor(Color.BLACK);

jhfm1=new JustifiedHorizontalFieldManager(lb1Sr, lbSr, true);
vfm.add(jhfm1);

jhfm2=new JustifiedHorizontalFieldManager(lb1Date, lbDate, true);
vfm.add(jhfm2);

jhfm3=new JustifiedHorizontalFieldManager(lb1Allo, lbAllo, true);
vfm.add(jhfm3);

jhfm4=new JustifiedHorizontalFieldManager(lb1Mob, lbMob, true);
vfm.add(jhfm4);

 hfm5=new JustifiedHorizontalFieldManager(lb1Detail, lbDetail, true);
vfm.add(jhfm5);

jhfm6=new JustifiedHorizontalFieldManager(lb1Remark, lbRemark, true);
vfm.add(jhfm6);

jhfm7=new JustifiedHorizontalFieldManager(lb1SlaDate, lbSlaDate, true);
vfm.add(jhfm7);

jhfm8=new JustifiedHorizontalFieldManager(lb1Email, lbEmail, true);
vfm.add(jhfm8);

jhfm9=new JustifiedHorizontalFieldManager(lb1Status, lbStatus, true);
vfm.add(jhfm9);

add(vfm);

我想使用两侧滚动选项显示所有数据。

4

1 回答 1

0

试试这个代码 -

VerticalFieldManager vfm=new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL);
LabelField date=new LabelField("Date :");
LabelField date_value=new LabelField(value);
JustifiedHorizontalFieldManager jfm_date=new JustifiedHorizontalFieldManager(date,date_value, true);
vfm.add(jfm_date);
LabelField name=new LabelField("Name:");
LabelField name_value=new LabelField(value);
JustifiedHorizontalFieldManager jfm_name=new JustifiedHorizontalFieldManager(name,name_value, true);
vfm.add(jfm_name);
add(vfm);

依此类推....添加所有这样的字段。

JustifiedHorizo​​ntalFieldManager 类如下 -

public class JustifiedHorizontalFieldManager extends Manager
{
    private static final int SYSTEM_STYLE_SHIFT = 32;

public Field _leftField;
public Field _rightField;

private boolean _giveLeftFieldPriority;

public JustifiedHorizontalFieldManager( Field leftField, Field rightField, boolean giveLeftFieldPriority )
{
    this( leftField, rightField, giveLeftFieldPriority, Field.USE_ALL_WIDTH );
}

public JustifiedHorizontalFieldManager( Field leftField, Field rightField, boolean giveLeftFieldPriority, long style )
{
    super( style );

    _leftField = leftField;
    _rightField = rightField;

    add( _leftField );
    add( _rightField );

    _giveLeftFieldPriority = giveLeftFieldPriority;
}

public JustifiedHorizontalFieldManager( boolean giveLeftFieldPriority, long style )
{
    super( style );
    _giveLeftFieldPriority = giveLeftFieldPriority;
}

public void addLeftField( Field field )
{
    if( _leftField != null ) {
        throw new IllegalStateException();
    }
    _leftField = field;
    add( _leftField );
}

public void addRightField( Field field )
{
    if( _rightField != null ) {
        throw new IllegalStateException();
    }
    _rightField = field;
    add( _rightField );
}

public int getPreferredWidth()
{
    return _leftField.getPreferredWidth() + _rightField.getPreferredWidth();
}

public int getPreferredHeight()
{
    return Math.max( _leftField.getPreferredHeight(), _rightField.getPreferredHeight() );
}

protected void sublayout( int width, int height )
{
    Field firstField;
    Field secondField;
    if( _giveLeftFieldPriority ) {
        firstField = _leftField;
        secondField = _rightField;
    } else {
        firstField = _rightField;
        secondField = _leftField;
    }

    int maxHeight = 0;

    int availableWidth = width;
    availableWidth -= _leftField.getMarginLeft();
    availableWidth -= Math.max( _leftField.getMarginRight(), _rightField.getMarginLeft() );
    availableWidth -= _rightField.getMarginRight();

    layoutChild( firstField, availableWidth, height - firstField.getMarginTop() - firstField.getMarginBottom() );
    maxHeight = Math.max( maxHeight, firstField.getMarginTop() + firstField.getHeight() + firstField.getMarginBottom() );
    availableWidth -= firstField.getWidth();

    layoutChild( secondField, availableWidth, height - secondField.getMarginTop() - secondField.getMarginBottom() );
    maxHeight = Math.max( maxHeight, secondField.getMarginTop() + secondField.getHeight() + secondField.getMarginBottom() );
    availableWidth -= secondField.getWidth();

    if( !isStyle( Field.USE_ALL_HEIGHT ) ) {
        height = maxHeight;
    }
    if( !isStyle( Field.USE_ALL_WIDTH ) ) {
        width -= availableWidth;
    }

    setPositionChild( _leftField, _leftField.getMarginLeft(), getFieldY( _leftField, height ) );
    setPositionChild( _rightField, width - _rightField.getWidth() - _rightField.getMarginRight(), getFieldY( _rightField, height ) );

    setExtent( width, height );
}

private int getFieldY( Field field, int height )
{
    switch( (int)( ( field.getStyle() & FIELD_VALIGN_MASK ) >> SYSTEM_STYLE_SHIFT ) ) {
        case (int)( FIELD_BOTTOM >> SYSTEM_STYLE_SHIFT ):
            return height - field.getHeight() - field.getMarginBottom();
        case (int)( FIELD_VCENTER >> SYSTEM_STYLE_SHIFT ):
            return field.getMarginTop() + ( height - field.getMarginTop() - field.getHeight() - field.getMarginBottom() ) / 2;
        default:
            return field.getMarginTop();
    }
}


public Field getLeftField()
{
    return _leftField;
}

public Field getRightField()
{
    return _rightField;
}

public void replace( Field oldField, Field newField )
{
    if( oldField == newField ) {
        // Nothing to do
        return;
    }

    if( oldField == _leftField ) {
        _leftField = newField;
    } else if( oldField == _rightField ) {
        _rightField = newField;
    }
    add( newField );
    delete( oldField );
}
}  
于 2012-06-28T12:59:58.487 回答