24
24
import android .view .View ;
25
25
import android .view .ViewGroup ;
26
26
import android .widget .Button ;
27
+ import android .widget .LinearLayout ;
27
28
import androidx .annotation .LayoutRes ;
28
29
import androidx .annotation .NonNull ;
29
30
import androidx .annotation .Nullable ;
@@ -45,9 +46,13 @@ public View onCreateDemoView(@NonNull LayoutInflater layoutInflater, @Nullable V
45
46
dockedToolbar = view .findViewById (R .id .docked_toolbar );
46
47
((AppCompatActivity ) requireActivity ()).setSupportActionBar (toolbar );
47
48
48
- Button leftArrowButton = view .findViewById (R .id .docked_toolbar_left_arrow_button );
49
- Button rightArrowButton = view .findViewById (R .id .docked_toolbar_right_arrow_button );
50
- Button addButton = view .findViewById (R .id .docked_toolbar_add_button );
49
+ LinearLayout dockedToolbarChild = view .findViewById (R .id .docked_toolbar_child );
50
+
51
+ View content = layoutInflater .inflate (getDockedToolbarContent (), dockedToolbarChild , /* attachToRoot= */ true );
52
+
53
+ Button leftArrowButton = content .findViewById (R .id .docked_toolbar_left_arrow_button );
54
+ Button rightArrowButton = content .findViewById (R .id .docked_toolbar_right_arrow_button );
55
+ Button addButton = content .findViewById (R .id .docked_toolbar_add_button );
51
56
setupSnackbarOnClick (leftArrowButton );
52
57
setupSnackbarOnClick (rightArrowButton );
53
58
setupSnackbarOnClick (addButton );
@@ -75,4 +80,9 @@ protected int getLayoutResId() {
75
80
public boolean shouldShowDefaultDemoActionBar () {
76
81
return false ;
77
82
}
83
+
84
+ @ LayoutRes
85
+ protected int getDockedToolbarContent () {
86
+ return R .layout .cat_docked_toolbar_small_content ;
87
+ }
78
88
}
0 commit comments