BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 04-29-2008, 02:44 AM   #1 (permalink)
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Custom Radio Buttons

Please Login to Remove!

Hi,

Can anyone please tell me if we can customize a radio button. I need two thigns to be done in here

1. Change the radio button image. The color of the circle when selected.
2. Display the radio button from right to left. I need radio buttons to be displayed on right side with text on the left.

Thanks in advance!!!
Offline  
Old 04-29-2008, 03:45 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You will have to create your own field or extend the existing RadioFieldButton and override it's layout and paint functions.

Maybe this article helps you to start:
How To - Create custom fields
Offline  
Old 04-29-2008, 03:47 AM   #3 (permalink)
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Ivanov,

Thanks for ur reply...thats what I have been trying to achieve here..but the problem that I am facing is ..i have customized all the elements like, layout, labels, buttons everything...but when i try the same for the radio buttons...i get the error...do u have any idea about how we can do it???

Hope to hear from you soon
Offline  
Old 04-29-2008, 03:51 AM   #4 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Never tried to extend the RadioFieldButton, but it should work if you do all the painting by yourself without calling paint() of the super class.
Do you have some code for us?
Offline  
Old 04-29-2008, 04:02 AM   #5 (permalink)
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I can give the code for buttons, field managers etc. but not for radio button...not able to create one :(
Offline  
Old 04-29-2008, 04:12 AM   #6 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You mentioned that you get en error, which is it?
Offline  
Old 04-29-2008, 04:17 AM   #7 (permalink)
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ohh...m sorry that was about tryin to align the radio button to right side and put a lebel field with the text on the left side...I was thinking about a custom layout with fixed height and varying height to put the labelfield with the text and put the radio button on the right side. The problem here I faced was that the setExtent() method require both height and width and I only want width to be fixed to the 80% of the screen and height should depend on the content.

If i dont use setExtend, then it uses the whole screen...That was the issue....
Either we get the radio button customized or else we can manage the fieldmanager to have fixed width and varying height...any of them will work...
Offline  
Old 04-29-2008, 04:43 AM   #8 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

can you post the code for the manager?
Offline  
Old 04-29-2008, 04:45 AM   #9 (permalink)
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here it is...all we have to do is to provide the height and width of the vertical manager...

package customElements;

import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.container.VerticalFieldManag er;

public class CustomVerticalLayout extends VerticalFieldManager
{
public CustomVerticalLayout()
{
super(VERTICAL_SCROLL|VERTICAL_SCROLLBAR);
}

int Width = 318;
int h= 120;
protected void sublayout(int maxWidth, int maxHeight)
{
super.sublayout(Width, h);
setExtent(Width, h);//This is where i want only the width but not the height...
}

public int getPreferredWidth()
{
return Width;
}

public int getPreferredHeight()
{
return h;
}
}

The height should remain incremental...which m not able to do right now...
Offline  
Old 04-29-2008, 05:13 AM   #10 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

It is still difficult for me to understand what you are trying to achieve. If your manager should be scrollable, it needs a fixed size on the visible screen.
Can you give more information about the behaviour of your user interface?

to calculate the height of your manager depending on the fields in it you can try this:

PHP Code:
    protected void sublayout(int maxWidthint maxHeight)
    {
        
super.sublayout(maxWidthmaxHeight);
        
        
int height 0;
        
int fieldcount getFieldCount();
        for (
int i=0fieldcounti++)
        {
            
height += getField(i).getHeight();
        }
        
setExtent(Width height);
    } 
Offline  
Old 04-29-2008, 05:17 AM   #11 (permalink)
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK..lets take it this way....I want half of the screen width to be used to display a label with multiple lines of text i.e. to accomodate the content the height should be increased but width should remain teh same, Now the point here is the custom layout can have a fixed width and height. But I dont know how many lines the text will occupy and hence cannot provide the height.
Offline  
Old 04-29-2008, 05:45 AM   #12 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

this should work.

PHP Code:
    protected void sublayout(int maxWidthint maxHeight)
    {
        
super.sublayout(maxWidthmaxHeight);
        
        
int height 0;
        
int fieldcount getFieldCount();
        for (
int i=0fieldcounti++)
        {
            
height += getField(i).getHeight();
        }
        
setExtent(maxWidth 2height);
    } 
however the height of the labelfield added to this manager was restricted to the half of the screens resolution during my tests. I'm not sure if it's a bug or RIM's restriction in their implementation of the LabelField. So I guess you have to implement your own LabelField too.

Also take a look at the TextBox field from the developer journal:
BlackBerry - BlackBerry | Wireless Handheld Devices, Software & Services from Research In Motion (RIM)
Offline  
Old 04-29-2008, 06:00 AM   #13 (permalink)
Thumbs Must Hurt
 
baran_khan's Avatar
 
Join Date: Apr 2008
Model: 9500
PIN: N/A
Carrier: Airtel
Posts: 110
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

YOU ROCK MY FRIEND......this took the toll on me...you just got it right..i used my already existing custom text field for the content and it did exactly what I wanted to do. Now i ll do the same using labelfield.

I ll bother you again should i face any trouble......

Thanks a million for ur help!!!!!!!!
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.