gpt4 book ai didi

java - 错误: void cannot be dereferenced

转载 作者:行者123 更新时间:2023-12-02 11:54:36 27 4
gpt4 key购买 nike

我正在尝试实现一个提供 map 标记动画的库,但是当我尝试添加一些高级方法时,它在第二个“.withFillColor(Color.BLUE)”上抛出一个错误,其中显示:错误: void 无法取消引用。

// mMap is GoogleMap object, latLng is the location on map from which ripple should start
actualUbicacion = new LatLng(3.385264, -76.526551);
mapRipple = new MapRipple(mMap, actualUbicacion, this)
.withNumberOfRipples(3) //int
.withFillColor(Color.BLUE) //here I get the error
.withStrokeColor(Color.BLACK) //if I delete the previous one, the next one gets the error
.withStrokewidth(10) // 10dp
.withDistance(2000) // 2000 metres radius
.withRippleDuration(12000) //12000ms
.withTransparency(0.5f);
mapRipple.startRippleMapAnimation(); //in onMapReadyCallBack

Error:(623, 17) error: void cannot be dereferenced

最佳答案

From Code

返回类型为void

public void withNumberOfRipples(int numberOfRipples) {
if (numberOfRipples > 4 || numberOfRipples < 1)
numberOfRipples = 4;
this.numberOfRipples = numberOfRipples;
}

因此您无法链接函数调用,您需要调用 MapRipple 实例上的每个函数,而不是 void

解决方案:将调用减少到单一级别

mapRipple = new MapRipple(mMap, actualUbicacion, this);
mapRipple.withNumberOfRipples(3);
mapRipple.withFillColor(Color.BLUE);
mapRipple.withStrokeColor(Color.BLACK);
mapRipple.withStrokewidth(10); // 10dp
mapRipple.withDistance(2000); // 2000 metres radius
mapRipple.withRippleDuration(12000); //12000ms
mapRipple.withTransparency(0.5f);
mapRipple.startRippleMapAnimation();

关于java - 错误: void cannot be dereferenced,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47688915/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com