BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 09-01-2008, 11:27 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2007
Model: 8900
OS: 4.6.1.94
PIN: N/A
Carrier: Swisscom / Orange CH
Posts: 29
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default BasicEditField.FIELD_RIGHT not working?

Please Login to Remove!

Hello,

I tried now for half an hour to get the BasicEditField at the right place but it's still left...

I used that command:
add(new BasicEditField("Car Taxes: ", "", 3,BasicEditField.FIELD_RIGHT));

But wont work...

An Idea?

What I would like is "Car Taxes: " on the left side and the input on the right side... possible?

Thanks a lot

Regards,
Yves

Last edited by Yves_ : 09-01-2008 at 11:49 AM.
Offline  
Old 09-01-2008, 12:23 PM   #2 (permalink)
CrackBerry Addict
 
Join Date: May 2005
Location: Golden, CO US
Model: 9700
Carrier: ATT
Posts: 684
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nothing available by default. Here's what I use...

Code:
class JustifiedEditField extends HorizontalFieldManager implements FieldChangeListener {

    WideLabelField lf;
    EditField ef;
    Font f;
    int dw = Display.getWidth();
    int rightMargin;
    
    public JustifiedEditField(String label, String value, int maxChars, long style) {
        super(USE_ALL_WIDTH);
        
        f = getFont();
        ef = new EditField(null, value, maxChars, style);
        ef.setChangeListener(this);

        lf = new WideLabelField(label);

        add(lf);
        add(ef);
        fieldChanged(ef, 0);
    }
    
    public String getText() {
        return ef.getText();
    }
    
    public void setRightMargin(int m) {
        rightMargin = m;
	fieldChanged(ef, 0);
    }
    public int getRightMargin() {
        return rightMargin;
    }

    public void fieldChanged(Field field, int context) {
        int efw = getFont().getAdvance(ef.getText());
        lf.setPreferredWidth(dw-efw-rightMargin);
    }
}

class WideLabelField extends LabelField {
    int width;
    
    WideLabelField(String label) {
        super(label);
    }
    
    public int getPreferredWidth() {
        return width;
    }
    
    public void setPreferredWidth(int width) {
        this.width = width;
        updateLayout();
    }
    
    protected void layout(int w, int height) {
        height = super.getPreferredHeight();
        super.layout(width, height);
        super.setExtent(width, height);
    }
}

Last edited by RemyJ : 09-01-2008 at 12:29 PM.
Offline  
Old 09-01-2008, 12:45 PM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2007
Model: 8900
OS: 4.6.1.94
PIN: N/A
Carrier: Swisscom / Orange CH
Posts: 29
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Looks complicated
Offline  
Old 09-01-2008, 01:00 PM   #4 (permalink)
CrackBerry Addict
 
Join Date: May 2005
Location: Golden, CO US
Model: 9700
Carrier: ATT
Posts: 684
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's STUPID. RIM should have something to do this.
Offline  
Old 09-01-2008, 01:39 PM   #5 (permalink)
CrackBerry Addict
 
Join Date: May 2005
Location: Golden, CO US
Model: 9700
Carrier: ATT
Posts: 684
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here's one that's a little less complicated.

Code:
class JustifiedEditField extends HorizontalFieldManager implements FieldChangeListener {

    LabelField lf;
    EditField ef;
    int dw = Display.getWidth();
    int rightMargin;
    
    public JustifiedEditField(String label, String value, int maxChars, long style) {
        super(USE_ALL_WIDTH);
        ef = new EditField(null, value, maxChars, style) {
            protected void onDisplay() {
                update(0);
            }
            protected void update(int d) {
                super.update(d);
                int efw = getFont().getAdvance(super.getText());
                setPosition(dw-efw-rightMargin,0);
            }
        };
        ef.setChangeListener(this);
        lf = new LabelField(label);
        add(lf);
        add(ef);
    }
    public String getText() {
        return ef.getText();
    }
    public void setRightMargin(int m) {
        rightMargin = m;
    }
    public int getRightMargin() {
        return rightMargin;
    }
    public void fieldChanged(Field field, int context) {
        invalidate();
    }

}
Offline  
Old 09-01-2008, 03:40 PM   #6 (permalink)
Knows Where the Search Button Is
 
Join Date: Apr 2007
Model: 8900
OS: 4.6.1.94
PIN: N/A
Carrier: Swisscom / Orange CH
Posts: 29
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot for your help RemyJ. I really appreciate it.
Offline  
Old 09-01-2008, 05:42 PM   #7 (permalink)
CrackBerry Addict
 
Join Date: May 2005
Location: Golden, CO US
Model: 9700
Carrier: ATT
Posts: 684
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

No problem.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.