2014-03-25 38 views
0

我是新的android開發者,所以我需要你的幫助。我正在製作一個應用程序,其中按鈕操作打開一個對話框。對話框有一個按鈕。我可以使用按鈕操作嗎?請給一些好的方法。謝謝Android Intent in對話框

回答

4

你想處理「確定」事件並執行一些操作。

你有一個方法來處理對話框。

public void displayAlertToChangeActivity(){ 
AlertDialog.Builder alert = new AlertDialog.Builder(this); 
alert.setTitle("title"); 
alert.setMessage("massage"); 

alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { 
    public void onClick(DialogInterface dialog, int whichButton) { 
    //Do something here where "ok" clicked and then perform intent from activity context 
    Intent intent = new Intent(MyActivity.this, MyNextActivity.class); 
    MyActivity.this.startActivity(intent); 

} 
}); 

alert.show(); 

}