2017-02-01 727 views
1

AlertDialog를 만든 다음 AlertDialog.Builder 자체를 표시하고 표시하는 주된 차이점은 무엇입니까?AlertDialog.Builder.show()와 Android의 AlertDialog.show()

예를 들면. 나는이 같은에 AlertDialog.Builder 수 있습니다 :

AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context); 
    dialogBuilder.setTitle("title"); 
    dialogBuilder.setMessage("message"); 
    dialogBuilder.setPositiveButton("OK", null); 

을 그리고 나는 두 가지 방법으로 표시 할 수 있습니다 : 다음 그냥 빌더에게

dialogBuilder.show(); 

을 보여주는

또는 빌더에서에 AlertDialog를 생성하고 보여 그

AlertDialog dialog = dialogBuilder.create(); 
dialog.show(); 
+2

빌더 내에서'create' 메소드를 호출하면 대화 상자의 참조를 얻을 수 있으므로 대화 상자 자체를 추가로 사용자 정의 할 수 있습니다. –

답변

2

모두 않습니다 같은 일 내부적으로

이 대화 상자를 만들고

public AlertDialog show() { 
     final AlertDialog dialog = create(); 
     dialog.show(); 
     return dialog; 
    } 

dialog.show() 반면 직접 show()를 호출 아래로 대화에 show()를 호출합니다

dialogBuilder.show() 대화 상자가 이미 생성 된 이후 대화 상자의 메소드

0
obj.create()-For create Dialog 

obj.show() - 표시 대화 상자 < - 사용자가 만든 경우 표시하지 않고 대화 상자를 표시 할 수 없습니다.

obj.create().show() -create 및 표시 대화 내가 한 성명에서이 상기와 같은 양을 의미한다.

하고 할 수도 있습니다 reffer android.com/guide/topics/ui/dialogs