2014-11-18 4 views
0

Google Play 서비스 가용성 확인을 사용 중이며 취소 버튼 (맞춤 cancelClickListener 포함)으로 ErrorDialog를 만들고 싶습니다. 그것을 성취 할 수있는 방법이 있습니까?GooglePlayServicesUtil의 ErrorDialog에 취소 버튼을 추가하는 방법은 무엇입니까?

공공 부울 isGooglePlayServicesAvailable() {

int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext()); 
    if (status == ConnectionResult.SUCCESS) { 
     return true; 
    }  
    else {   
     int requestCode = 10; 
     Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);   
     dialog.setCanceledOnTouchOutside(false); 
     dialog.setOnKeyListener(new DialogInterface.OnKeyListener() { 
      @Override 
      public boolean onKey(DialogInterface dialog, int keyCode, 
        KeyEvent event) { 
       if (keyCode == KeyEvent.KEYCODE_BACK) { 
        ... 
        return true; 
       } 
       return false; 
      } 
     }); 
     dialog.show(); 
     return false; 
    } 


} 

답변

1

아니, GooglePlayServicesUtil 방법은 대화 아닌에 AlertDialog를 반환하기 때문에.

이러한 종류의 사용자 지정 동작이 필요한 경우 결과에 대한 작업 시작, 주어진 상태 코드에 대한 적절한 오류 메시지 표시 등을 처리하는 자체 AlertDialog (또는 이와 비슷한)를 구현해야합니다. 궁금한 점이 있다면 - 취소를 원할 경우 setCanceledOnTouchOutside(true)을 사용하고 OnKeyListener을 설정하지 마십시오.

+0

감사합니다. 그냥 간단한 방법이 있기를 바랍니다. – user2944063

관련 문제