@@ -483,7 +483,7 @@ private MenuItem addMenuItemForButton(@NonNull Menu menu, @NonNull Button button
483483 }
484484 MaterialButtonGroup .LayoutParams lp =
485485 (MaterialButtonGroup .LayoutParams ) button .getLayoutParams ();
486- String text = OverflowUtils .getMenuItemText (button , lp .overflowText );
486+ CharSequence text = OverflowUtils .getMenuItemText (button , lp .overflowText );
487487 Drawable icon = lp .overflowIcon ;
488488 MenuItem item = menu .add (text );
489489 if (icon != null ) {
@@ -1121,7 +1121,7 @@ protected boolean checkLayoutParams(@NonNull ViewGroup.LayoutParams p) {
11211121 /** A {@link LinearLayout.LayoutParams} implementation for {@link MaterialButtonGroup}. */
11221122 public static class LayoutParams extends LinearLayout .LayoutParams {
11231123 @ Nullable public Drawable overflowIcon = null ;
1124- @ Nullable public String overflowText = null ;
1124+ @ Nullable public CharSequence overflowText = null ;
11251125
11261126 /**
11271127 * Creates a new set of layout parameters. The values are extracted from the supplied attributes
@@ -1138,7 +1138,7 @@ public LayoutParams(@NonNull Context context, @Nullable AttributeSet attrs) {
11381138 overflowIcon =
11391139 attributes .getDrawable (R .styleable .MaterialButtonGroup_Layout_layout_overflowIcon );
11401140 overflowText =
1141- attributes .getString (R .styleable .MaterialButtonGroup_Layout_layout_overflowText );
1141+ attributes .getText (R .styleable .MaterialButtonGroup_Layout_layout_overflowText );
11421142
11431143 attributes .recycle ();
11441144 }
@@ -1161,14 +1161,14 @@ public LayoutParams(int width, int height, float weight) {
11611161 * in pixels
11621162 * @param weight the weight
11631163 * @param overflowIcon the overflow icon drawable
1164- * @param overflowText the overflow text string
1164+ * @param overflowText the overflow text char sequence
11651165 */
11661166 public LayoutParams (
11671167 int width ,
11681168 int height ,
11691169 float weight ,
11701170 @ Nullable Drawable overflowIcon ,
1171- @ Nullable String overflowText ) {
1171+ @ Nullable CharSequence overflowText ) {
11721172 super (width , height , weight );
11731173 this .overflowIcon = overflowIcon ;
11741174 this .overflowText = overflowText ;
@@ -1209,17 +1209,17 @@ public static class OverflowUtils {
12091209 private OverflowUtils () {}
12101210
12111211 @ Nullable
1212- public static String getMenuItemText (@ NonNull View view , @ Nullable String text ) {
1212+ public static CharSequence getMenuItemText (@ NonNull View view , @ Nullable CharSequence text ) {
12131213 if (!TextUtils .isEmpty (text )) {
12141214 return text ;
12151215 }
12161216 if (view instanceof MaterialButton && !TextUtils .isEmpty (((MaterialButton ) view ).getText ())) {
12171217 // Use button's text if overflow text is not specified or empty. We don't do this to icon,
12181218 // since icon in menu item is optional.
1219- return (String ) ( (MaterialButton ) view ).getText ();
1219+ return ((MaterialButton ) view ).getText ();
12201220 }
12211221 // As a last resort, use content description.
1222- return ( String ) view .getContentDescription ();
1222+ return view .getContentDescription ();
12231223 }
12241224 }
12251225}
0 commit comments