外国語で「はい/いいえ」の確認ダイアログを作成する必要があります。Dialogを拡張して独自のクラスを作成する必要があると思いますか?
ありがとう
外国語で「はい/いいえ」の確認ダイアログを作成する必要があります。Dialogを拡張して独自のクラスを作成する必要があると思いますか?
ありがとう
これでうまくいくはずです。スウェーデン人シェフが見ていることをお詫びします。
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);
編集:
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);
上記からわかるように、このメソッドを使用するだけでダイアログのすべてのテキスト(言語)値を変更できるため、別の言語でダイアログを作成するためのカスタムクラスは必要ありません。
標準の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;
}
上記では、新しい画面を作成し、sublayoutメソッドをオーバーライドして、layoutDelegateでカスタムの幅、高さ、およびxyの位置を指定しました。この画面を押すと、指定したXY位置にあるスタックの前の画面の上にあるボックスのようなダイアログとして表示されます。
必ずpushModalを使用してください。これにより、画面が表示スタックからポップされた後、getExitStateメソッドにアクセスできるようになります。
例えば
MyDialogScreen dialog = new MyDialogScreen();
UiApplication.getUiApplication().pushModalScreen(dialog);
int result = dialog.getExitState();
乾杯
レイ