BlackBerry Hyperlinks alignment - blackberry

I'm developing a BlackBerry Native Application BB SDK 5.0.
I want the Ui of this format.
--text-- --Hyperlink-- --text--
and so on.
This means i can have hyperlinks in-between the sentences.
So when i tried to make this, i'm facing some alignment issues.
Word wrap occurs and this leaves a large white space in right side of the screen.
To simulate i have attached a prototype of my code.
LabelField mylabel1 = new LabelField("Label 11231 23123123",LabelField.FIELD_LEFT);
LabelField mylabel2 = new LabelField("Label2",LabelField.FIELD_RIGHT);
LabelField mylabel3 = new LabelField("Label 312312 3123",LabelField.FIELD_RIGHT);
LabelField mylabel4 = new LabelField("Label 41312 3123",LabelField.FIELD_RIGHT);
LabelField mylabel5 = new LabelField("Label5",LabelField.FIELD_RIGHT);
LabelField mylabel6 = new LabelField("Label6",LabelField.FIELD_RIGHT);
LabelField mylabel7 = new LabelField("Label7",LabelField.FIELD_RIGHT);
LabelField mylabel8 = new LabelField("Label8",LabelField.FIELD_RIGHT);
FlowFieldManager hr=new FlowFieldManager(FlowFieldManager.USE_ALL_WIDTH);
hr.add(mylabel1);
hr.add(mylabel2);
hr.add(mylabel3);
hr.add(mylabel4);
hr.add(mylabel5);
hr.add(mylabel6);
hr.add(mylabel7);
hr.add(mylabel8);
add(hr);

Related

radio button not visible in a HorizontalFieldManager in blackberry?

I am working on a blackberry application which includes radio button controls.
HorizontalFieldManager hr = new HorizontalFieldManager();
setTitle("UI Component Sample");
RadioButtonGroup rbg = new RadioButtonGroup();
RadioButtonField r1 = new RadioButtonField("Option 1",rbg,true);
RadioButtonField r2 = new RadioButtonField("Option 2",rbg,false);
hr.add(r1);
hr.add(r2);
add(hr);
Working with this code I can see my both radio buttons in curve device but when I install my app in Torch device, only 1st radio button is visible on the screen.
Getting problem in showing one radio group in a horizontal field.
It works when i use a vertical field for a group.
And Horizontal and vertical both works when i works on curve device.
Please suggest what type of bus or problem this is.
In OS 6, RadioButtonField causes some problem regarding its width. Overriding the layout(int, int) method may solve your problem. Try following code.
RadioButtonGroup rbg = new RadioButtonGroup();
RadioButtonField rbf = new RadioButtonField("Label", rbg, true) {
protected void layout(int width, int height) {
super.layout(getPreferredWidth(), height);
}
};

How to set transparent background to LabelField in BlackBerry

I am trying to create a LabelField with no background at all, as a transparent one. I have a background set to my screen with a bitmap and I would like to have my LabelField transparent.
I have the following code but it does not work.
BitmapField info;
EncodedImage logoBitmap = EncodedImage.getEncodedImageResource("userInfo.png");
info = new BitmapField(null, Field.FIELD_LEFT |Field.FIELD_BOTTOM);
info.setImage(logoBitmap);
AbsoluteFieldManager superMainContainer;
superMainContainer.add(info,0,200);
LabelField nameLabel = new LabelField("Name:");
nameLabel.setBackground(BackgroundFactory.createSolidTransparentBackground(0, 0));
superMainContainer.add(nameLabel, 10, 210);
[Updated]
Following code snippet is working on my simulator. Difference between the following one and your code is only some initialization code.
Bitmap bm = Bitmap.getBitmapResource("image.png");
BitmapField info = new BitmapField(bm, Field.FIELD_LEFT
| Field.FIELD_BOTTOM);
LabelField lbl = new LabelField("LabelField Text");
lbl.setBackground(BackgroundFactory.createSolidTransparentBackground(0, 0));
AbsoluteFieldManager superMainContainer = new AbsoluteFieldManager();
superMainContainer.add(info, 0, 200);
superMainContainer.add(lbl, 10, 210);
MainScreen screen = new MainScreen();
screen.add(superMainContainer);
UiApplication.getUiApplication().pushScreen(screen);
[Old]
LabelField lbl;
lbl.setBackground(BackgroundFactory.createSolidTransparentBackground(0, 0));
You didn't initialize the LabelField - nameLabel before applying Background.
And you don't need to set any Background instance for getting a transparent background, the default LabelField will work for this case.

create popup screen in blackBerry

I want to create a popup screen in BlackBerry like the screen appear on long click (see the picture)
My screen contain 3 items
image description
image description
image description
Can any one help me by an example or link to do this popup?
Use the below code and call the GetPopup wherever you want to show the pop up screen
final class Getpopup extends PopupScreen
{
EditField edf;
AutoTextEditField edf1;
HorizontalFieldManager hfm;
public Getpopup()
{
super( new VerticalFieldManager());
LabelField lf = new LabelField("Contact Info", LabelField.FIELD_HCENTER);
SeparatorField sf = new SeparatorField();
edf1= new AutoTextEditField("Name:","" ,20,EditField.NO_NEWLINE);
edf = new EditField("Number:",ThirdScreen.get3);
edf.setEditable(false);
VerticalFieldManager vfm =new VerticalFieldManager(VerticalFieldManager.FIELD_HCENTER);
hfm=new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER);
ButtonField bf1 = new ButtonField("Save", ButtonField.FIELD_HCENTER);
ButtonField bf2 = new ButtonField("Cancel", ButtonField.FIELD_HCENTER);
hfm.add(bf1);
hfm.add(bf2);
vfm.add(lf);
vfm.add(sf);
vfm.add(edf1);
vfm.add(edf);
vfm.add(hfm);
add(vfm);
}
}
Find the code here to create creating-borderless-transparent-popup screen in blackberry
If your looking for custmizing the Buttons as appeared in image then visit custom-image-buttonfield-in-blackberry
You have to make use of GridFieldManager.java for the layout you have used, Also you can customize your own layout.
Create a PopupDialog class which extends Dialog and then in the constructor, add the Buttons. If you would like your buttons to look like the above image, extend a field or button field and in paint method, draw the button and then the button text below the button. Add this custom button control in the PopupDialog.

need help with Field Managers Blackberry

I keep getting an IllegalArgumentException and nothing shows on the BlackBerry simulator when I run this code. What could be wrong with it?
public MyScreen()
{
// Set the displayed title of the screen and add the weather icons
setTitle("PixWeather");
cityField = new LabelField("Queensland", Field.FIELD_LEFT);
tempField = new LabelField("17", Field.FIELD_RIGHT);
condField = new LabelField("sunny",Field.FIELD_RIGHT);
weather_icon = Bitmap.getBitmapResource("sun_icon.png");
bitmapField = new BitmapField(weather_icon, Field.FIELD_LEFT);
VerticalFieldManager vfield = new VerticalFieldManager();
HorizontalFieldManager hfield1 = new HorizontalFieldManager();
hfield1.add(cityField);
hfield1.add(tempField);
HorizontalFieldManager hfield2 = new HorizontalFieldManager();
hfield2.add(bitmapField);
hfield2.add(condField);
vfield.add(hfield1);
vfield.add(hfield2);
}
The IllegalArgumentException could be unrelated, but nothing is showing up on your screen because you didn't add anything to your screen.
You need to add the vfield to the screen itself. Add the following line:
add(vfield);

Trying to draw a bitmap on blackberry

I'm just learing how to program the blackberry and trying to display a bitmap on the screen, here is the code:
public MyScreen()
{
// Set the displayed title of the screen
setTitle("MyTitle2");
LabelField lb = new LabelField("hello ted2");
add(lb);
Bitmap logoBitmap = Bitmap.getBitmapResource("res/icon2.png");
BitmapField fd= new BitmapField(logoBitmap, Field.FIELD_HCENTER);
add(fd);
}
The label is drawn but not the bitmap.
Your path is wrong, copy the image into /res/img. To retrieve that, use the file name only.
Bitmap logoBitmap = Bitmap.getBitmapResource("icon2.png");
I think you need to put the two fields into a VerticalFieldManager:
public MyScreen()
{
VerticalFieldManager vfm = new VerticalFieldManager();
// Set the displayed title of the screen
setTitle("MyTitle2");
LabelField lb = new LabelField("hello ted2");
vfm.add(lb);
Bitmap logoBitmap = Bitmap.getBitmapResource("res/icon2.png");
BitmapField fd= new BitmapField(logoBitmap);
vfm.add(fd);
add(vfm);
}

Resources