2012-01-13 13 views
0

私はこのコードを作った。ダイアログで「OK」ボタンが押されると、例外が発生してアプリがクラッシュします。なぜ、何か助けを見つけることができないのですか?私はAndroidのドキュメントからこれらの指示に従ってきました。アンドロイド "android.view.WindowLeaked:"例外

package com.grawl.faqplus; 

import android.app.Activity; 
import android.app.AlertDialog; 
import android.content.DialogInterface; 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 

public class FAQPlusActivity extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     // Set up buttons 

     Button buttonExit = (Button) findViewById(R.id.button_exit); 
     Button buttonAbout = (Button) findViewById(R.id.button_about); 

     // Set up AlertDialog for buttonAbout 

     String aboutMessage = (String) getString(R.string.dialog_about); 

     AlertDialog.Builder builderAbout = new AlertDialog.Builder(this); 
     builderAbout.setMessage(aboutMessage); 
     builderAbout.setCancelable(false); 
     builderAbout.setNeutralButton("OK!", new DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialog, int id) { 
       finish(); 
      } 
     }); 
     final AlertDialog alertAbout = builderAbout.create(); 

     // Show about dialog 

     buttonAbout.setOnClickListener(new OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       alertAbout.show(); 
      } 
     }); 

     // Exit app 

     buttonExit.setOnClickListener(new OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       finish(); 
       System.exit(0); 
      } 
     });  
    } 
} 
+1

http://stackoverflow.com/questions/2850573/activity-has-leaked-window-that-was-と

finish(); 

を置き換えることによってそれを修正元々追加された –

答えて

2

Iは

dialog.dismiss(); 
関連する問題