小编Ath*_*ena的帖子

未解决的参考:TabLayoutMediator

我正在开发一个需要TabLayout绑定到ViewPager2. 阅读本文并遵循此处的代码,我需要使用TabLayoutMediator. 但是在导入时,我遇到了Unresolved reference错误。我知道这个错误指的是什么,但我在依赖项和导致错误的东西中找不到任何问题。正如第二个链接中提到的,这个类包含在androidx.viewpager2:viewpager2:1.0.0-beta03其中是链接所讨论内容的更新版本。我还尝试将版本降级到链接中提到的版本,但效果不佳。这是我的build.gradle文件:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.myapp"
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation …
Run Code Online (Sandbox Code Playgroud)

android kotlin android-tablayout android-viewpager2

8
推荐指数
1
解决办法
7012
查看次数