本文共 765 字,大约阅读时间需要 2 分钟。
书中在build.gradle文件内使用的是compile命令,现在不再支持,将命令改为implementation,如下:
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'com.android.support:recyclerview-v7:24.2.1' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'}
相应地,在xml文件中引用recyclerView控件时,使用androidx库,标签如下:
这里需要添加一个layout-large/activity_main.xml,不过操作的时候会报错:重复文件名(尽管这个与默认的activity_main.xml不在同一个路径下),这似乎是AS新增的功能,如下图:
解决方法: 右键layout-large–>New–>layoutsoursefile即可(最后一步不要点那个xml),如下图:转载地址:http://huwai.baihongyu.com/