请问把Dialog声明为final有什么好处?
public class AlertDialogStudy extends Activity {14 /** Called when the activity is first created. */15 @Override16 public void onCreate(Bundle savedInstanceState) {17 super.onCreate(savedInstanceState);18 setContentView(R.layout.main);19 20 // get button21 Button btnShow = (Button)findViewById(R.id.btn_show);22 btnShow.setOnClickListener(new View.OnClickListener() {23 24 @Override25 public void onClick(View v) {26 AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());27 builder.setTitle("Auto-closing Dialog");28 builder.setMessage("After 2 second, this dialog will be closed automatically!");29 builder.setCancelable(true);30 31 final AlertDialog dlg = builder.create();32 33 dlg.show();34 35 final Timer t = new Timer();36 t.schedule(new TimerTask() {37 public void run() {38 dlg.dismiss(); // when the task active then close the dialog39 t.cancel(); // also just top the timer thread, otherwise, you may receive a crash report40 }41 }, 2000); // after 2 second (or 2000 miliseconds), the task will be active.42 43 }44 });45 }46 }