为什么我不能覆盖onAttachFragment?

时间:2016-08-02 22:24:59

标签: android fragment android-support-library

我有一个从android.support.v4.app.Fragment扩展的类。文档android.support.v4.app.Fragment显示有一个名为onAttachFragment(Fragment childFragment)的方法,但我无法在Android Studio中覆盖它。它就像它不存在。这有什么原因,或者这是文档中的错误? android.app.Fragment非支持版本表示它已在API级别24中添加。但这应该无关紧要吗?因为我使用的是具有相同类的支持版本。

编辑: 这是我在build.gradle中的依赖项

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile project(':core-3.2.1')
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.google.android.gms:play-services:7.8+'
    compile 'com.microsoft.azure.android:azure-storage-android:0.7.0@aar'
}

1 个答案:

答案 0 :(得分:2)

您正在使用支持库的23.4.0版本。只有支持库的24.X(即24.1.1)版本才会包含API 24中添加的等效API。

您需要升级支持库版本才能使用新API。