android 開發中fragment 遇到的問題
http://yifeng.studio/2016/12/15/android-fragment-attentions/
1、不要輕易在 fragment中引用 getactivity();
解決方案 1.判斷getacitvity()!=null 和 this.isadd();
2.用這個里面的context
@Override
public void onAttach(Context context) {
super.onAttach(context);
this.context=context;
}
3.
getContext().getApplicationContext(); 用詞context
2、就是 fragment 和activity 相互調用 傳遞數據的問題 上面的網址有 再一個用eventbus用 (比較方便。。。)
3、就是當內存不夠的話 會銷毀activity 當重新打開此activitiy oncreate方法時 會重新創建fragment 從而會出現重疊的情況 至于解決方案上面的url有很好的辦法
浙公網安備 33010602011771號