How to create custom Dialogue box and add listeners to the buttons in the dialogue box in blackberry
Asked
Active
Viewed 1,343 times
1 Answers
5
public class CustomDialog extends Screen implements FieldChangeListener
{
private ButtonField okButton;
public void fieldChanged(Field field, int context)
{
if (field == okButton)
{
close();
}
}
public CustomDialog(String message)
{
super(new VerticalFieldManager(), Screen.DEFAULT_CLOSE);
add(new LabelField("Search Error",LabelField.FIELD_HCENTER));
add(new LabelField(""));
add(new LabelField(message,LabelField.FIELD_HCENTER));
add(new LabelField(""));
okButton = new ButtonField("OK",ButtonField.FIELD_HCENTER);
okButton.setChangeListener(this);
add(okButton);
}
protected void paintBackground(Graphics graphics)
{
graphics.setColor(Color.GRAY);
graphics.fillRoundRect(0, 0, getWidth(), getHeight(), 12, 12);
graphics.setColor(Color.BLACK);
graphics.drawRoundRect(0, 0, getWidth(), getHeight(), 12, 12);
}
protected void sublayout(int width, int height)
{
layoutDelegate(width - 80, height - 80);
setPositionDelegate(10, 10);
setExtent(width - 60, Math.min(height - 60, getDelegate().getHeight() + 20));
setPosition(30, (height - getHeight())/2);
}
}
-
1what problems you are facing..? – Dec 29 '11 at 04:33
-
it was my mistake. Nw it works fine. Thank u for ur help dear. Can i ask u a doubt? I need to display a message only for the first time user uses my app. once that message is displayed, it wont be show again. how can i do it? Is there anything there for blackberry? (just someting like sharedpreference in Android) – Dil Se... Dec 29 '11 at 04:37
-
you can use persistent storage for that – BBdev Feb 28 '12 at 09:30