我在尋找soultion預25.2.0
FragmentManager.FragmentLifecycleCallbacks
是從25.1.0
。關於這個API的25.2.0
中引入的唯一更改是became static
,在此之前它只是一個公共內部類。爲了這意味着使用您通過它的外圍實例,在這種情況下是FragmentManager
訪問它:
final FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.registerFragmentLifecycleCallbacks(fragmentManager.new FragmentLifecycleCallbacks() {
@Override
public void onFragmentPreAttached(FragmentManager fm, Fragment f, Context context) {
super.onFragmentPreAttached(fm, f, context);
}
...
// all other callbacks
}, true);
正如Eugen Pechanec's comment提到的,默認的框架片段(即android.app.Fragment
,不支持包)will receive these changes在Android-O
發佈。
您可以跟蹤支持庫[此處](https://developer.android.com/topic/libraries/support-library/revisions.html)中的更改。任何特定原因不更新? –