[問題] 獨立出一個method來切換activity

看板AndroidDev作者 (夏天是喵艾發呆的季節)時間10年前 (2015/07/09 05:09), 10年前編輯推噓0(002)
留言2則, 1人參與, 最新討論串1/1
public class Core_ChangeActController { public static void Core_ChangeActController(Activity a, Class b , boolean c ) { Intent intent = new Intent(); intent.setClass(a, b); 這行出錯>> Context.startActivity(intent); a.finish(); } } Cannot make a static reference to the non-static method startActivity(Intent) from the type Context 錯誤提示是這樣... 不是很懂 >< -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 122.118.44.95 ※ 文章網址: https://www.ptt.cc/bbs/AndroidDev/M.1436389769.A.937.html

07/09 05:29, , 1F
startActivity不是static method,要有instance才能呼叫
07/09 05:29, 1F

07/09 05:30, , 2F
a.startActivity
07/09 05:30, 2F
感謝 的確這樣後可以跑了 ※ 編輯: aynmeow (122.118.44.95), 07/09/2015 06:18:43
文章代碼(AID): #1LdP69at (AndroidDev)