我试图实现一个提供地图标记动画的库,但是当我尝试添加一些高级方法时,它会在第二个方法上引发错误" .withFillColor(Color.BLUE)& #34;其中说:错误:无法取消引用虚空。
// 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
答案 0 :(得分:1)
返回类型为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();