问题描述
当我尝试使用RecyclerView在测试项目时,我将要尝试的是Android 5.0棒棒糖,我看到了下面就谷歌网站:
1),令我百思不解的是,他们使用的支持的事,而不是真实的东西在API 21.我期待不使用,因为我运行在设备上5.0的支持包提供的,有21 SDK下载和安装。为什么不能我只是用RecyclerView直接,无需使用支持...?
2)类无法找到
在Android Studio中,我得到这个错误:
元素RecyclerView在这里不允许没有进一步的信息。另外,如果我用如上张贴的例子中,我得到了同样的错误:
如果我点击修复构建路径,我看到的:
我一直在使用JAVA和Android这些问题,但该错误消息是不清楚。该SDK的路径(在SDK位置)是正确的。
这是我的gradle:
应用插件:'com.android.application安卓{
compileSdkVersion 21
buildToolsVersion19.1.0 defaultConfig {
的applicationIDse.snap code.lollipoptest
21的minSdkVersion
targetSdkVersion 21
版本code 1
的versionName1.0
}
buildTypes {
发布 {
runProguard假
proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
}
}
}依赖{
编译文件树(导演:'库',包括:['的* .jar'])
}
这是我的清单:
<?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=se.snap code.lollipoptest> <采用-SDK安卓的minSdkVersion =21
机器人:targetSdkVersion =21/> <应用
机器人:allowBackup =真
机器人:图标=@绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ AppTheme>
<活动
机器人:名字=。MainActivity
机器人:标签=@字符串/ APP_NAME>
&所述;意图滤光器>
<作用机器人:名字=android.intent.action.MAIN/> <类机器人:名字=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT;
< /用途>< /清单>
由于我完全破坏了我的第一个答案,让我们再次从顶级试试这个...
The is no "real" thing. RecyclerView
is only in the Android Support package, via the recyclerview-v7
library project/AAR.
This is akin to how Google packages ViewPager
(support-v4
and support-v13
), CardView
(cardview-v7
), the Leanback UI for Android TV (leanback-v17
), etc.
The Android Support libraries is not just a set of backports. It does include various classes that are only available via those libraries. In addition to the above, there is NavUtils
, FileProvider
, and various other classes that are "native" to the Android Support libraries.
So, if you want RecyclerView
, add recyclerview-v7
to your project, such as via Android Studio:
or via your app
module's build.gradle
:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:recyclerview-v7:21.0.0'
}
这篇关于支持VS"真正的"图书馆"类找不到"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!