带API 21的小吃店 [英] Snackbar with API 21

查看:198
本文介绍了带API 21的小吃店的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的应用程序中实现新的Snackbars,但我不能。首先,我从这个SnackBarSampleActivity

我解压缩它,然后我在Eclipse中导入它。现在,在 styles.xml 中的主题父项中,我收到一个错误检索父级...

我将其更改为 android:Theme.Light ,错误消失了。我右键单击该项目并在Properties / Android中检查isLibrary,我右键单击我的应用程序,并在Properties / Android中添加库。最后,我粘贴代码以显示一个 Snackbar ,但是我收到错误,因为 Snackbar无法解析

请有人帮我!我疯了,我做错了什么?

解决方案

您应该尝试使用Android Studio,因为Eclipse的ADT插件不再处于活动开发中。



在Android Studio中,您只需添加一行 compile'c​​om.nispok:snackbar:2.6.1'在您的 build.gradle 依赖关系中,这样

 依赖关系{
compile fileTree(dir:'libs',include:['* .jar'])
compile'c​​om.android.support:appcompat-v7:21.0.2'
compile'c​​om。 nispok:snackbar:2.6.1'
}

就是这样。 b $ b

I'm trying to implement the new Snackbars in my app but I can't. First of all I downloaded the zip file from this SnackBarSampleActivity.
I unziped it and then I import it in Eclipse. Now I get an error retrieving parent... for the theme parent in styles.xml.
I change it to android:Theme.Light and the error was gone. I right clicked the project and checked isLibrary in Properties/Android, I right clicked my app and in Properties/Android I add the library. Finally I paste the code to show a Snackbar but I get an error because Snackbar cannot be resolved.
Please somebody help me! I'm going crazy, what am I doing wrong?

解决方案

You should try to use Android Studio, because the ADT plugin for Eclipse is no longer in active development.

In Android Studio, you just need to add a line compile 'com.nispok:snackbar:2.6.1' in your build.gradle dependencies, such that

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.2'
    compile 'com.nispok:snackbar:2.6.1'
}

That's it.

这篇关于带API 21的小吃店的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆