Arg0:<string name= "Red_number" > Quantity%1$s</string>
</pre><pre name= "code" class= "java" style= "Background-color:rgb (255, 255, 255); ">ARG1:" 123456 "
<span style= "Background-color:rgb (255, 255, 255); "> Show Effect: Quantity </span><span style=" Background-color:rgb (255, 102, 102); " >123456</span>
</pre><pre name= "code" class= "Java" >
/** * * @param context * @param arg0 string * @param arg1 number * @return */public spannablestringbuilder setred (Con Text context, int arg0, string arg1) {string text = String.Format (Context.getresources (). getString (arg0), arg1); int index [] = new Int[1];index[0] = Text.indexof (arg1);//index[1] = Text.indexof ("+");//index[2] = Text.indexof ("Silver Chest"); Spannablestringbuilder style = new Spannablestringbuilder (text); Style.setspan (new Foregroundcolorspan (Color.RED), Index[0],index[0] + arg1.length (), spannable.span_exclusive_inclusive)//style.setspan (New ForegroundColorSpan ( color.red), index[1],//index[1] + 2, spannable.span_exclusive_inclusive);//style.setspan (New BackgroundColorSpan ( color.red), Index[2],//index[2] + 3, spannable.span_exclusive_inclusive); return style;}
That's it...
Android string Partial discoloration: