2011-03-07 5 views

답변

5

이 트릭을 수행해야합니다. 스웨덴 요리사가보고있는 것에 대해 사과드립니다.

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); 

당신은 당신이 필요해서는 안이 방법을 사용하여 위의이 대화 상자의 모든 텍스트 (언어) 값을 변경할 수 있습니다에서 볼 수 있듯이 다른 언어로 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; 
    } 

위의 나는 새 화면을 만들었습니다 그리고 난에서 사용자 지정 너비, 높이 및 XY 위치를 지정하는 sublayout 방법을 재정의 layoutDelegate. 이 화면을 누르면 지정한 XY 위치에있는 스택의 이전 화면 위에있는 상자 모양의 대화 상자로 표시됩니다.

pushModal을 사용해야합니다. 이렇게하면 화면이 디스플레이 스택에서 팝업 된 후 getExitState 메소드에 액세스 할 수 있습니다.

예컨대

MyDialogScreen dialog = new MyDialogScreen(); 
UiApplication.getUiApplication().pushModalScreen(dialog); 
int result = dialog.getExitState(); 

건배

레이

관련 문제