27
27
import android .widget .TextView ;
28
28
import androidx .annotation .ColorInt ;
29
29
import androidx .annotation .IdRes ;
30
+ import androidx .annotation .LayoutRes ;
30
31
import androidx .annotation .NonNull ;
31
32
import androidx .annotation .Nullable ;
32
33
import com .google .android .material .button .MaterialButton ;
@@ -47,10 +48,7 @@ public View onCreateDemoView(
47
48
@ Nullable ViewGroup viewGroup ,
48
49
@ Nullable Bundle bundle ) {
49
50
50
- View view =
51
- layoutInflater .inflate (
52
- R .layout .cat_floating_toolbar_fragment , viewGroup , /* attachToRoot= */ false );
53
-
51
+ View view = layoutInflater .inflate (getLayoutResId (), viewGroup , /* attachToRoot= */ false );
54
52
TextView bodyText = view .findViewById (R .id .body_text );
55
53
56
54
// Initialize group of floating toolbars.
@@ -131,7 +129,8 @@ public View onCreateDemoView(
131
129
view , floatingToolbars , R .id .bottom_button , R .id .floating_toolbar_bottom );
132
130
initializeOrientationButton (
133
131
view , floatingToolbars , R .id .left_button , R .id .floating_toolbar_left );
134
- initializeOrientationButton (view , floatingToolbars , R .id .right_button , R .id .floating_toolbar_right );
132
+ initializeOrientationButton (
133
+ view , floatingToolbars , R .id .right_button , R .id .floating_toolbar_right );
135
134
136
135
// Select bottom configuration button to represent the toolbar that's initially visible.
137
136
view .findViewById (R .id .bottom_button ).performClick ();
@@ -182,4 +181,9 @@ private int getRandomColor() {
182
181
final int bound = 256 ;
183
182
return Color .rgb (random .nextInt (bound ), random .nextInt (bound ), random .nextInt (bound ));
184
183
}
184
+
185
+ @ LayoutRes
186
+ protected int getLayoutResId () {
187
+ return R .layout .cat_floating_toolbar_fragment ;
188
+ }
185
189
}
0 commit comments