Fragment的onAttach方法不调用的问题
以下是stackflow上的答案
It’s not called because this method has been added in API 23. If you run your application on a device with API 23 (marshmallow) then onAttach(Context) will be called. On all previous AndroidVersions onAttach(Activity) will be called.
即onAttach(Context context)方法,在API 23中才加入,低于该版本就不会被调用。
解决方案
一、使用v4包中的Fragment来代替
二、可以用onAttach(Activity activity)代替