Blackberry Custom ButtonField with no Border - blackberry

how could i create a custom ButtonField with no border in Blackberry...
any help will be appreciated

bingo, just add the applyTheme() method
class BitmapButtonField extends ButtonField {
protected void applyTheme()
{
}
}
Arhimed & Rafael, thanks for you help!

Use this tutorial to create your own custom field.
Control the appearance of your field in paint() method.

Yes, this is possible by extending Field. You just need to create 2 images (one for a focused state and one for an unfocused state). Just don't draw the border on those images.
A sample implementation can be found here.

As Arhimed said, you should extend Field. This will give you the maximum amount of customization over how the button looks.
Here's an example of a customizable button I've created: https://github.com/HeshamMegid/BlackBerry-Custom-Controls
You could use it as it is or modify the code further to suit your needs.

Related

How to create focusable horizontal field manager in Blackberry

I need focusable horizontal field manager,for this i found some code in forums.
hfm[i]=new HorizontalFieldManager(HorizontalFieldManager.FOCUSABLE)
{
protected void onFocus(int direction)
{
Background bg = BackgroundFactory.createLinearGradientBackground(0x00E2E2E2,0x00E2E2E2,0x00E2E2E2,0x00E2E2E2);
setBackground(bg);
}
protected void onUnfocus()
{
Background bg = BackgroundFactory.createLinearGradientBackground(0x00FFFFFF,0x00FFFFFF,0x00FFFFFF,0x00FFFFFF);
setBackground(bg);
}
};
rtf[i]=new ExtendedLabel(list[i]);
hfm[i].add(rtf[i]);
add(hfm[i]);
But the it is not focusable,if it
You should also add this method to your new HorizontalFieldManager
public boolean isFocusable(){
return true;
}
Remember though when you set a manager to be focusable in this way it must have a field within it that is focusable or else you will get a null exception when the screen tries to give your managae focus.
This is a known problem that happens to everyone at least one time.
I started a topic in BB support forum:
Scroll happening but Vertical Field Manager Not Moving
And the answer given was the blackberry support forum article:
My scrollable manager is not scrolling
That is not a real answer but is the only workaround that's available for the moment
Another posible solution to this is:
A friend gave me the solution... you can put your manager into an
horizontal manager and then you can just add an nullfield with a
focusable behaviour, This will do the trick
You can try that.
You give focus to this.
rtf[i]=new ExtendedLabel(list[i]);
as....
rtf[i]=new ExtendedLabel(list[i],Field.Focusable);

How to set non focusable labelField inside a GridField

I have developed a application with considering touch screen device for BlackBerry.
But when I am trying to use it in Non touch screen device all the lable also shows the focus.
Basically what I want that LabelField should not show any focus.
I have set NonFocusable Property for it but still it is not working.
Please help me out.
Thanks in advance...
You dont want the LabelField to have focus when you select it on touchscreen ?
Extend LabelField and override onFocus like so -
protected void onFocus(int direction) {
}
Also try overriding the LabelField's isFocusable() to always return false. It's possible that the GFM is just calling setFocus() on the next field without checking whether or not it can actually accept focus. If this is the case you may have to override the GFM's nextFocus() method and correct the logic.

Blackberry - ButtonField Controls Paint method

I am extending the ButtonField and overriding the paint method to show the buttons in a differnet color. But its painting the whole button width. Part of the button stil shows as Gray when there is no focus and blue when its on focus. Can you please help me to resolve this issue?
thanks,
ramesh
You'll have to override protected void applyTheme() to disable the extra painting that is going on.

How can I change the default highlighted color of focused ListField row?

Can anybody help me on this?
I tried to override onFocus(), onUnfocus() and paint() methods of ListField.
Please do a simple web search before post to stackoverflow.
Please go through the following links.
Create a Custom Listfield - Change Highlight Color when Scrolling by John Banks
Blackberry Tip: Change the default focus highlight color of ListField by Yincan Sheng

BlackBerry: TreeField with BitmapField

I want to display the contacts in a TreeField like:
An image followed by a username
My understanding is that I use a BitmapField to display the image, but I don't see how to combine a BitmapField with a TreeField.
You can't use another field with a TreeField. You need to implement the TreeFieldCallback.drawTreeItem() method and do the drawing yourself
See my answer to a similar StackOverflow question: "Customising Blackberry Treefield."
In that answer, I've re-drawn each row of a TreeField along with a Bitmap image replacing the default (+)-icon of TreeField.
You can do it by using graphics.drawBitmap() method and graphics.drawText() method and using the index and y parameters inside the drawTreeItem() method of class which implements TreeFieldCallback interface

Resources