Re: [J2ME] 呼叫MIDlet內的方法

看板java作者 (allstars)時間17年前 (2008/07/13 14:56), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《Qed (捲)》之銘言: : public class MainMIDlet extends MIDlet : { : public Class1 obj1; : public MainMIDlet() {..} : public void startApp() {..} : public void pauseApp() {..} : public void destroyApp(boolean unconditional) {..} : public void doExit() {..} //加了這方法 : } : 請問一下我要怎麼從obj1呼叫doExit() : MainMIDlet有實體化名稱嗎 add reference to MainMIDlet in the constructor of Class1 like public Class1(MainMIDlet midlet) { this.midlet=midlet; ..... } void foo() { .. midlet.doExit(); .. } 在obj1 new時就 例如在MainMIDlet的context裡的話 就obj1=new Class1(this); //'this' is a ref to MainMIDlet 如果你要的是terminate的function的話 可以call MIDlet的 destroyApp() , notifyDestroyed() 不知道你要的是不是這樣 我是來賺p幣的................... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.166.220.93

07/19 08:59, , 1F
感謝!
07/19 08:59, 1F
文章代碼(AID): #18UQS6wl (java)
文章代碼(AID): #18UQS6wl (java)