如何使用小吃吧不支持库? [英] How to use Snackbar without support library?

查看:182
本文介绍了如何使用小吃吧不支持库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Android应用程序不需要向后兼容。目标SDK版本是22到现在为止。我使用的本地活动和片段和应用的主题是安卓Theme.Material.Light。
我的问题是,我无法使用小吃吧与现有设置,它抛出异常像

I am developing an Android app which doesn't require backward compatibility. Target SDK version is 22 as of now. I am using native Activity and Fragment and application theme is android:Theme.Material.Light. My problem is that I'm not able to use Snackbar with the existing setup, it throws exceptions like

android.view.InflateException:二进制XML文件行#18:错误充气类android.support.design.widget.Snackbar $ SnackbarLayout E / AndroidRuntime(19107):在android.view.LayoutInflater.createView(LayoutInflater.java: 640)E / AndroidRuntime(19107):在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)

android.view.InflateException: Binary XML file line #18: Error inflating class android.support.design.widget.Snackbar$SnackbarLayout E/AndroidRuntime(19107): at android.view.LayoutInflater.createView(LayoutInflater.java:640) E/AndroidRuntime(19107): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)

我用Google搜索,但未能找到小吃店活动的任何实例。因此,它是需要使用支持库像

I googled but couldn't find any example of snackbar with Activity. So is it necessary to use support library like

AppCompatActivity或android.support.v4.app.Fragment。

AppCompatActivity or android.support.v4.app.Fragment.

为了我的应用程序使用小吃吧?

in order to use Snackbar in my app?

推荐答案

您需要使用支持设计库编译com.android.support:design:23.0.1'为它工作:

You need to use the support design library compile 'com.android.support:design:23.0.1' for it to work:

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

了解更多详细这里

这篇关于如何使用小吃吧不支持库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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