2011-05-15 2 views
0

제목이 "위치가 파일에 저장되었습니다"라는 AlertDialog가 표시되지 않습니다. 사용자가 첫 번째 대화 상자에서 Okay를 누른 후 표시되어야하는 대화 상자입니다.Android : 이전 대화 상자에서 사용자가 "확인"을 클릭 한 후 대화 상자를 표시하는 방법

스레드와 관련이 있다고 생각하지만 잘 모르겠습니다. 당신이 패턴을 사용하는 경우

 SimpleDateFormat timeStampFormat = new SimpleDateFormat("MMMMM-dd-yyyy"); 


     final EditText input = new EditText(EncounterActivity.this); 
     input.setWidth(75); 
     input.setText("Bear-Encounter-GPS-" + timeStampFormat.format(new Date()) + ".txt"); 

     new AlertDialog.Builder(EncounterActivity.this) 
     .setTitle("Save GPS Location") 
     .setMessage("Please enter a filename") 
     .setView(input) 
     .setIcon(R.drawable.gps) 
     .setPositiveButton("Save", new DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialog, int whichButton) { 
       try { 
        File root = Environment.getExternalStorageDirectory(); 
        if (root.canWrite()){ 
         File fn = new File(root, input.getText().toString()); 
         FileWriter gpxwriter = new FileWriter(fn); 
         BufferedWriter out = new BufferedWriter(gpxwriter); 
         out.write(ll.toUTMRef().toString()); 
         out.close(); 



         AlertDialog.Builder builder = new AlertDialog.Builder(EncounterActivity.this); 
         builder.setIcon(R.drawable.gps); 
         builder.setTitle("Location was saved to file"); 
         builder.setMessage("Your GPS coordinates were saved to " + fn.getAbsolutePath()) 
           .setPositiveButton("Okay", new DialogInterface.OnClickListener() { 
            public void onClick(DialogInterface dialog, int id) { 

            } 
           }); 
         AlertDialog alert = builder.create(); 
         alert.show(); 

        } 
       } catch (IOException e) { 
        //ProfitBandit.alert(Shipment.this, "Couldn't write the file."); 
        Log.v("IOException", "Could not write file " + e.getMessage()); 
       } 
      } 
     }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialog, int whichButton) { 
       // Do nothing. 
      } 
     }).show(); 

답변

0

당신은 경고 대화 상자에서 경고 대화 상자를 표시 할 수 있습니다 ShowDialog를 (int)를 getInstanceSomeDialog과이 onCreateDialog 모두 대화 상자에 대한 (INT). 그래서 aboutAlertDialog 내에서 :

builder.setPositiveButton("View EULA", new DialogInterface.OnClickListener() { 
    public void onClick(DialogInterface dialog, int id) {    //cancels itself? 
     showDialog(DIALOG_EULA_SHOW); 
    }  
}); 

차례로 또 다른 AlertDialog에 EULA를 표시합니다. 또는 토스트를 토스트 할 수 있습니다.

Toast.makeText(Main.this,"Location Saved.", Toast.LENGTH_SHORT).show(); 

여기서 Main은 액티비티 클래스입니다.

관련 문제