很明显,有包没有导入,把zhuli下的包都放到libs里面
猜测发生的原因:关于TabLayout 你是直接复制的代码吧?如果你手动敲Tab编译器不会提示你有TabLayout,而是TableLayout之类的;
解决:检查一下你这个module的build.gradle文件是否有添加 com.android.support:design:28.0.0 依赖
具体代码:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// 添加 下面这句,后面的 28.0.0 参考 上面的implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
}
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:design:26.1.0'
加入这2个依赖就行了,版本号自己修改