首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到RippleDrawable

找不到RippleDrawable
EN

Stack Overflow用户
提问于 2015-07-17 11:00:27
回答 2查看 42.3K关注 0票数 10

我想动态地在代码中创建一个涟漪。

代码:

代码语言:javascript
复制
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      buyButton.setBackground(getPressedColorRippleDrawable(primaryColor, darkerVariant));
}

public static RippleDrawable getPressedColorRippleDrawable(int color, int darkerVariant) {
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ColorStateList colorStateList = new ColorStateList(
                new int[][]
                        {new int[]{}},
                new int[]
                        {darkerVariant}
        );
        return new RippleDrawable(colorStateList, new ColorDrawable(color), null);
    }
    return null;
}

这在Lollipop上是可行的,但却使应用程序在我的GNEX (4.3)上崩溃。

错误:

无法找到类‘android.Graphics.draable.RippleDrawable’,引用于方法fragments.ProductDetailFragment.getPressedColorRippleDrawable 07-17 12:57:45.757 30992-30992/com.comizzo.ginsonline E/AndroidRuntime:致命例外: main java.lang.VerifyError:片段/产品碎片

但是RippleDrawable从来没有在Gnex上使用,因为代码没有被执行。

我怎么才能解决这个问题?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-03-10 05:11:14

问题是,您需要在getPressedColorRippleDrawable中返回一个可绘制的而不是一个getPressedColorRippleDrawable。否则,在前棒棒糖设备上,您将得到一个VerifyError。

票数 8
EN

Stack Overflow用户

发布于 2015-07-17 13:01:42

这段代码确实没有被执行。这个应用程序崩溃是因为你收到了一个java.lang.VerifyError。如果使用EclipseandBuild → Rebuild project,如果使用Android,请尝试执行Build → Rebuild project

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31474297

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档