Tuesday, April 16, 2013

[android help] Android Toast with multi-colors


Try doing this i hope this is what you realyy want



richTextView = (TextView)findViewById(R.id.rich_text);

// this is the text we'll be operating on
SpannableString text = new SpannableString("hello how are you");

// make "hello" to (characters 0 to 5) red color
text.setSpan(new ForegroundColorSpan(Color.RED), 0, 5, 0);

richTextView.setText(text, BufferType.SPANNABLE);


And if you want it to show it as toast try this instead of setText use it like this



Toast.makeText(context, text, Toast.LENGTH_LONG).show();


enter image description here



.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...