2012-12-13 3 views
0

코드가 작동하지 않습니다. 도와주세요. 그것은 모든 문자열을 대체하지만 더 많은 코드가 실행되지 않습니다.안드로이드의 경고 상자가 작동하지 않습니다.

디버깅 할 때 코드에 오류가 없습니다. 경고 상자의 코드가 표시됩니다.

if(count>0) 

      { 
       System.out.println("replace all string name "); 
       // final Intent intent_ul=new Intent(this, UploadExcel.class); 
       AlertDialog.Builder alertDialogBuilder_ue = new AlertDialog.Builder(this);    
       alertDialogBuilder_ue.setTitle("Alert!!"); 
       alertDialogBuilder_ue 
        .setMessage("Are you sure you want to Replace all the data related to this style ? ") 

        .setCancelable(false) 
        .setPositiveButton("Yes",new DialogInterface.OnClickListener() { 
         public void onClick(DialogInterface dialog,int id) { 
          mySQLiteAdapter.openToWrite(); 
           mySQLiteAdapter.delete_style_measurement(style_no); 
           Log.d("","yes click"); 
           count=0; 
           mySQLiteAdapter.close(); 

         } 
        }) 
        .setNegativeButton("No",new DialogInterface.OnClickListener() { 
         public void onClick(DialogInterface dialog,int id) { 
          Log.d("","No click"); 
          count++; 
          dialog.cancel(); 
          // startActivity(intent_ul); 
          //finish(); 
         } 
        }); 
      } 

답변

0

은이 코드를 사용하여 코드에서

0

확인

alertDialogBuilder_ue.show(); 

를 추가해야합니다. 나

Context context = CurrentActivity.this; 
AlertDialog.Builder ad = new AlertDialog.Builder(context); 
ad.setTitle("Application"); 
ad.setMessage("Do you want to proceed?"); 
ad.setPositiveButton("Yes", new OnClickListener() 
{ 
public void onClick(DialogInterface dialog, int arg1) 
{ 

} 
}); 
ad.setNegativeButton("Cancel", new OnClickListener() 
{ 
public void onClick(DialogInterface dialog, int arg1) 
{ 

} 
}); 
ad.setCancelable(false); 
ad.show(); 
1

근무이 코드는 대화 상자가 나타납니다해야 alertDialogBuilder_ue.show();를 추가하는 코드에서 조건 경우

AlertDialog alertDialog = alertDialogBuilder_ue.create(); 
alertDialog.show(); 
+0

'에 AlertDialog에 AlertDialog = alertDialogBuilder_ue.create()에 대한 핸들이 필요하지 않을 경우 .create() 옵션을 사용이없는 ,'라인을? 'alertDialogBuilder_ue'는 무엇입니까 –

+1

alertDialogBuilder_ue는 alertdialog를 생성 할 수있는 빌더 객체입니다. 빌더 객체를 직접 사용하여 경고 대화 상자를 표시 할 수 없습니다. 먼저 AlerDialog의 인스턴스를 가져온 다음 show()를 호출해야합니다. –

0

이 끝나기 전에 다음 줄을 추가합니다. 당신이 당신이 다음에 .show() 방법을 사용할 수 있습니다 AlertDialog에 대한 핸들을 얻을 수 alertDialogBuilder_ue.create();를 사용하는이 제안 된 몇몇 사람들에 의해

.

둘 가능성이있다 그러나 당신은 당신이 설명 할 수있는 AlertDialog

관련 문제