为什么在我试图将状态设置为STATE_SETTLING时BottomSheetBehavior抛出java.lang.IllegalArgumentException:非法状态参数:2

时间:2019-06-20 09:47:48

标签: android bottom-sheet

我有一种方法可以对地图单击进行操作,当我单击地图时,该方法试图将状态设置为STATE_SETTLING,但会抛出IllegalArgumentException

我已经检查了该状态是否不在STATE_HIDDENSTATE_SETTLING中,并且isHideabletrue,但是它抛出了java.lang.IllegalArgumentException: Illegal state argument: 2 。我试图将状态设置为STATE_EXPANDEDSTATE_HALF_EXPENDED,这些状态运行良好,但不是我想要的。

fun onMapClickListener(zonesViewModel: ZonesViewModel){
    if(zonesViewModel.merchantInfoBottomLayout!!.state != BottomSheetBehavior.STATE_HIDDEN || zonesViewModel.merchantInfoBottomLayout!!.state != BottomSheetBehavior.STATE_SETTLING){
        zonesViewModel.merchantInfoBottomLayout!!.isHideable = true
        zonesViewModel.merchantInfoBottomLayout!!.state = BottomSheetBehavior.STATE_SETTLING
    }

    }
}

崩溃日志:

E / Android运行时:致命异常:主要     java.lang.IllegalArgumentException:非法状态参数:2         在android.support.design.widget.BottomSheetBehavior.startSettlingAnimation(BottomSheetBehavior.java:755)         在android.support.design.widget.BottomSheetBehavior.setState(BottomSheetBehavior.java:650)         在。* .. MerchantsZoneLocationHandler.onMapClickListener(MerchantsZoneLocationHandler.kt:171)         在。* .. ZonesFragment $ setupMerchantsComponents $ 2.onMapClick(ZonesFragment.kt:119)         在com.mapbox.mapboxsdk.maps.MapGestureDetector.notifyOnMapClickListeners(MapGestureDetector.java:882)         在com.mapbox.mapboxsdk.maps.MapGestureDetector $ StandardGestureListener.onSingleTapConfirmed(MapGestureDetector.java:327)         at com.mapbox.android.gestures.StandardGestureDetector $ 1.onSingleTapConfirmed(StandardGestureDetector.java:81)         在android.view.GestureDetector $ GestureHandler.handleMessage(GestureDetector.java:300)         在android.os.Handler.dispatchMessage(Handler.java:102)         在android.os.Looper.loop(Looper.java:165)         在android.app.ActivityThread.main(ActivityThread.java:6375)         在java.lang.reflect.Method.invoke(本机方法)         在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:912)         在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)

1 个答案:

答案 0 :(得分:0)

问题已解决,我需要稍微更改一下代码,而我尝试将状态设置为ObservableCollection<LoadedJockeys>时却抛出了public async Task<ObservableCollection<T>> UpdateDataAsync<T>(ObservableCollection<T> genericCollection, int idFrom, int idTo, string jobType) if (jobType.Contains("Horses")) { ObservableCollection<LoadedHorses> horses = genericCollection; } else if (jobType.Contains("Jockeys")) { ObservableCollection<LoadedJockeys> jockeys = genericCollection; } ,我只是将代码更改为STATE_SETTLINGIllegalArgumentException