Activity要如何結束?
我的程式main有四個選項
其中最後一項是"離開",就是直接關掉此程式
我查到以下資訊,但我不會使用onDestroy()
public class Activity extends ApplicationContext {
protected void onCreate(Bundle savedInstanceState);
protected void onStart();
protected void onRestart();
protected void onResume();
protected void onPause();
protected void onStop();
protected void onDestroy();
}如下
如果要切換至其他Activity (main→readFile)
我可以這樣寫
private Button.OnClickListener readFile = new Button.OnClickListener()
{
public void onClick(View v)
{
Intent intent = new Intent();
intent.setClass(main.this, readFile.class);
startActivity(intent);
}
};
那如果只是要關掉程式該怎麼寫?
好像不是直接在onClick()裡加onDestroy()?
已完成
謝謝












![[睡眠達人SL6102]國家專利 2.5mm強力獨立筒床墊+釋壓記憶綿 標準單人 MIT 送USB保](https://www.iarticlesnet.com/pub/img/article/36597/1408395418995_xs.jpg)
![[睡眠達人SL6102]國家專利 2.5mm強力獨立筒床墊+釋壓記憶綿 標準雙人 MIT 送USB保](https://www.iarticlesnet.com/pub/img/article/36598/1408395452411_xs.jpg)




![選哪部 最佳小型平板之戰: 詳細比較 iPad mini vs Nexus 7 [中文影片]](https://www.iarticlesnet.com/pub/img/article/11036/1403849224458_s.jpg)



