に関連付けられていない私は、私は今、私はBottomSheetBehaviourを追加するためにそれを参照するとき、私が取得BottomSheetBehaviour:ビューがBottomSheetBehavior
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
との相対的なレイアウトを持っている私の活動では Googleのデザインサポートライブラリ25.0.0を使用していますここでエラー
java.lang.IllegalArgumentException: The view is not associated with BottomSheetBehavior
はレイアウトです:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/maps_colayout"
xmlns:app="http://schemas.android.com/tools"
android:fitsSystemWindows="true"
android:background="@color/white">
...
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="280dp"
android:layout_gravity="bottom"
android:id="@+id/rl_bottomsheet"
android:background="#F3F3F3"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
...
</RelativeLayout>
そしてここでは、活動関連するコードです:
CoordinatorLayout colayout = (CoordinatorLayout) findViewById(R.id.maps_colayout);
View bottomSheet = colayout.findViewById(R.id.rl_bottomsheet);
BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);
behavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
// React to state change
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
// React to dragging events
}
});
これはうまくいきました。/toolsまたは/ apk/res-autoをいつ使うべきかを知るには –
答えが更新されました。 –