【问题标题】:I stuck on android method FloatMath.floor API does not issue我坚持使用 android 方法 FloatMath.floor API 没有问题
【发布时间】:2015-09-11 12:47:56
【问题描述】:

方法:

@Override
protected boolean isReadyForPullEnd() {
    @SuppressWarnings("deprecation")
    float exactContentHeight = FloatMath.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale());
    return mRefreshableView.getScrollY() >= (exactContentHeight - mRefreshableView.getHeight());
}

输出: Error:(116, 39) error: cannot find symbol method floor(float)

有什么办法可以解决这个问题吗?

【问题讨论】:

  • 更多详细信息 - 注意:一些输入文件使用或覆盖已弃用的 API。 - 注意:使用 -Xlint:deprecation 重新编译以获取详细信息。

标签: android android-studio window floor


【解决方案1】:

FloatMath 实用程序类已弃用。请改用 Math.floor。

【讨论】:

  • 不只是弃用 but "所有方法都已从版本 23 中的公共 API 中删除。"
  • 当我将它转到“Math.floor”时,它显示“需要不兼容的类型:发现浮点数:双精度”我该怎么办?
  • @AphikritGerbertSaravasri 将其转换为像这样浮动。 float exactContentHeight = Math.floor((float)mRefreshableView.getContentHeight() * mRefreshableView.getScale());
【解决方案2】:

FloatMath 和 getScale() 都已弃用。请改用以下代码

double exactContentHeight = Math.floor(mRefreshableView.getContentHeight() * getResources().getDisplayMetrics().density);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-12
    • 2021-10-11
    • 2013-04-10
    • 2022-01-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多