GridViewPager的Android Studio渲染问题(Android Wear)

瓦伦丁

每次我在布局中使用android.support.wearable.view.GridViewPager时,都会在编辑器中收到此错误。

GridViewPager NullPointerException

Rendering Problems
java.lang.NullPointerException
  at android.support.wearable.view.GridViewPager.recomputeScrollPosition(GridViewPager.java:1236)
  at android.support.wearable.view.GridViewPager.onSizeChanged(GridViewPager.java:1190)
  at android.view.View.sizeChange(View.java:15083)
  at android.view.View.setFrame(View.java:15056)
  at android.view.View.layout(View.java:14964)
  at android.view.ViewGroup.layout(ViewGroup.java:4631)
  at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
  at android.view.View.layout(View.java:14968)
  at android.view.ViewGroup.layout(ViewGroup.java:4631)
  at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
  at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
  at android.view.View.layout(View.java:14968)
  at android.view.ViewGroup.layout(ViewGroup.java:4631)

有人知道如何解决这个问题吗?

谢谢

马蒂阿什人

com.google.android.support:wearable您使用哪个版本因为这看起来可能是中的(已修复)错误GridViewPager

如果比较该类的1.0.0版和1.1.0版之间的相关行,则可以看到缺少缺失的空值检查,该空位检查稍后进行了更改。在1.0.0版中:

ItemInfo ii = infoForPosition(this.mCurItem);
int targetX = ii != null ? computePageLeft(ii.positionX) - getPaddingLeft() : 0;
int targetY = ii != null ? computePageTop(ii.positionY) - getPaddingTop() : 0;

// NPE in following line (1236), only possible if ii == null.
if ((targetX != getScrollX(ii.positionY)) || (targetY != getScrollY()))
{
   ...

而1.1.0版是:

ItemInfo ii = infoForPosition(this.mCurItem);
if (ii != null) // <- check is moved here.
{
    int targetX = computePageLeft(ii.positionX) - getPaddingLeft();
    int targetY = computePageTop(ii.positionY) - getPaddingTop();
    if ((targetX != getRowScrollX(ii.positionY)) || (targetY != getScrollY()))
    {
        ...

我会尝试更新和重建。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章