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.
Related
I am trying to build a screen in BlackBerry. In which there should be a second title bar just below the original title bar. Also the second title bar should be fixed and it should not be scrolled with vertical scroll.
Need some advice on this issue.
You can add the second title and the original title bar on a VerticalFieldManager. Then just set that VerticalFieldManager as title, as it's possible to set any Field, Manager instance as title.
Check public void setTitle(Field title) and following example.
public class DemoScreen extends MainScreen {
public DemoScreen() {
super();
// Prepare a Custom Title
long style = NO_VERTICAL_SCROLL | NO_VERTICAL_SCROLLBAR | USE_ALL_WIDTH;
VerticalFieldManager myTitle = new VerticalFieldManager(style);
// Set background color.
myTitle.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
// Add any numbers/types of field
myTitle.add(new LabelField("First line."));
myTitle.add(new LabelField("The second line."));
// Set the Title
setTitle(myTitle);
}
}
My application have one screen below the detail of that. Screen name EventList . This screen have designed full. There are two ButtonField Next and Previous . At the bottom of these two Button ListField is placed in this screen.
When i click on Next or Previous my ListField will update . It is updated successfully using updateListField() method which is created in this screen. All is working fine up to this. But my concern is that when i click on these Button ListField will take time (around 3 or 4 second)to update new data. During my data updating in background i want to show Massage like Please wait.../Loading.... How can i show this without using PopupScreen.
i had tried the below code but not working properly.
VerticalFieldManager manager = new VerticalFieldManager();
manager.add(new LabelField("Please Wait..."));
Screen popup = new PopupScreen(manager);
If i will done this using PopupScreen my full logic will be change for that screen and it will time consuming task.
Please suggest me how can we add FieldManager on existing MainScreen.
Thanks in Advance !!!
The MainScreen class includes a status field that you can use for this. In your class extending MainScreen add:
setStatus(new LabelField("Please wait..."));
to remove that status:
setStatus(null);
However, you need to do this on the event thread and then return so the OS can update the user interface. If you are performing the update of your list on the event thread (the thread that will call your code when the button is pressed) then you should perform that work on a spearate thread and use UiApplication.invokeLater() or hold the event lock to perform updates on the user interface.
Application.getApplication().invokeLater(
new Runnable() {
public void run() {
GIFEncodedImage image;
EncodedImage encodedImage = EncodedImage
.getEncodedImageResource("spiral.gif");
byte data[] = new byte[3000];
data = encodedImage.getData();
image = (GIFEncodedImage) EncodedImage
.createEncodedImage(
data, 0,
data.length);
AnimatedGIFField animatedGIF = new AnimatedGIFField(
image);
PopupScreen popup = new PopupScreen(
new VerticalFieldManager());
popup.add(animatedGIF);
Border border = BorderFactory
.createSimpleBorder(
new XYEdges(),
Border.STYLE_SOLID);
popup.setBorder(border);
UiApplication
.getUiApplication()
.pushScreen(popup);
Timer timer = new Timer();
timer.schedule(new CountDown(),
3000);
}
});
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);
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);
}
I want to know how to create VerticalFieldManager and i want to add some components also.
Couple of options:
A basic vertical field manager:
VerticalFieldManager vfm = new VerticalFieldManager();
// add your fields
vfm.add(new LabelField("First Label");
vfm.add(new LabelField("Second Label");
// etc
// then don't forget to add your vertical field manager to your screen
// assuming you're in the screen's constructor:
add(vfm);
The labels will appear top to bottom in the order you add them.
If you're going to add more fields than will fit vertically on a screen, you may want to make your manager scrollable:
VerticalFieldManager vfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
// the rest is the same as above
You can omit VERTICAL_SCROLLBAR if you don't want to see the up/down arrows.
But finally, if you just want a bunch of fields vertically on a screen, MainScreen by default uses a scrolling VerticalFieldManager as its delegate so you can just add fields directly and get the same effect:
class MyScreen extends MainScreen {
public MyScreen() {
add(new LabelField("Label 1");
add(new LabelField("Label 2");
// etc
}
}
Creation :
VerticalFieldManager vfm = new VerticalFieldManager();
Add different fields to it:
vfm.add(somefield);