2011-12-19 44 views
0

在我的AlertDialog中,我只添加了一個按鈕。當我點擊這個按鈕時,我希望我回到家中。AlertDialog有一個按鈕來重置應用程序

這是代碼:

 AlertDialog alertDialog = new AlertDialog.Builder(Main.this).create(); 
     alertDialog.setTitle("Débit !!"); 
     alertDialog.setMessage("Votre débit de téléchargement est "+deb); 
     alertDialog.setButton("OK", new DialogInterface.OnClickListener() {      

      public void onClick(DialogInterface dialog, int which) { 

      } 
     }); 
     alertDialog.setIcon(R.drawable.icon); 
     alertDialog.show(); 

我知道我需要在public void onClick(DialogInterface dialog, int which)添加一些行。但是,我不知道我會放什麼。

請,我需要你的建議。

+0

什麼是「家」你的應用程序的家庭活動或只是去主屏幕的時期? – 2011-12-19 19:50:29

回答

1

如果您正在嘗試在您的應用程序中執行特定活動,則應該這樣做。

alertDialog.setButton("OK", new DialogInterface.OnClickListener() {      

     public void onClick(DialogInterface dialog, int which) { 

     Intent i = new Intent(Your_class.this, YOur_class_you_want_to_start.class); 
     startActivity(i); 



     } 
    }); 
+1

就是這樣** coder_For_Life22 **。它工作清晰 謝謝 – Linconnue55 2011-12-19 20:14:19

相關問題