2
如何创建自定义对话框,并在黑莓在自定义对话框黑莓
如何创建自定义对话框,并在黑莓在自定义对话框黑莓
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);
}
}
添加侦听在对话框中的按钮尝试这样做。但没有成功 – 2011-12-28 06:24:51
你面临什么问题..? – 2011-12-29 04:33:35
这是我的错误。它工作正常。亲爱的,谢谢你的帮助。我可以问你一个疑问吗?我只需要在第一次用户使用我的应用时显示一条消息。一旦显示该消息,就不会再显示。我该怎么做?黑莓手机有什么吗? (就像Android中的sharedpreference一样) – 2011-12-29 04:37:25