这应该可以解决问题.我对任何瑞典厨师的观看表示歉意.
int answer = Dialog.ask("Gersh gurndy morn-dee burn-dee, burn-dee, flip-flip-flip-flip-flip-flip-flip-flip-flip?", new String[] {"Hokey dokey","Bork bork bork"}, new int[] {Dialog.OK,Dialog.CANCEL}, Dialog.CANCEL);
Run Code Online (Sandbox Code Playgroud)
编辑:
The above explained better:
public final static int NEGATIVE = 0;
public final static int AFIRMATIVE = 1;
public final static int DEFAULT = NEGATIVE;
int answer = Dialog.ask("question?", new String[] {"afirmative button label", "negative button label"}, new int[] {AFIRMATIVE,NEGATIVE}, DEFAULT);
Run Code Online (Sandbox Code Playgroud)
从上面可以看出,只需使用此方法就可以更改Dialog上的所有文本(语言)值,因此您不需要自定义类来创建另一种语言的Dialog.
如果你使用标准的BB本地化方法更简单,那么更简单的方法(Dialog.ask(res.getString(SOMEQUESTION))将自动拥有它的肯定和负面按钮根据手机选项中设置的语言进行调整.你只需要添加作为字符串资源的问题.
您可以在此处找到有效方法和构造函数的列表:http: //www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/ui/component/Dialog.html
更多编辑如下:
我认为我的上述答案就是你所追求的,但如果你确实需要在新课程中进一步自定义对话框,你可以这样做:
public class MyDialogScreen extends MainScreen implements LocalResource {
private int exitState;
...
protected void sublayout( int width, int height ) {
setExtent( dialogWidth, dialogHeight );
setPosition( XPOS, YPOS );
layoutDelegate( dialogWidth, dialogHeight );
}
// do some stuff and assign exitState appropriately
// e.g. a button that sets exitState = 1 then pops this screen
// another button that sets exitState = 2 then pops this screen
...
public int getExitState()
{
return this.exitState;
}
Run Code Online (Sandbox Code Playgroud)
在上面我创建了一个新的屏幕,我已经覆盖了sublayout方法,以在layoutDelegate中指定自定义的宽度,高度和xy位置.当您按下此屏幕时,您将在指定的XY位置将其视为堆栈上一个屏幕上方的对话框.
确保使用pushModal.这将允许您在从显示堆栈弹出屏幕后访问getExitState方法.
例如
MyDialogScreen dialog = new MyDialogScreen();
UiApplication.getUiApplication().pushModalScreen(dialog);
int result = dialog.getExitState();
Run Code Online (Sandbox Code Playgroud)
干杯
射线
| 归档时间: |
|
| 查看次数: |
3584 次 |
| 最近记录: |