01.// Get our EditText object. 02.EditText vw = (EditText)findViewById(R.id.text); 03. 04.// Set the EditText's text. 05.vw.setText("Italic, highlighted, bold."); 06. 07.// If this were just a TextView, we could do: 08.// vw.setText("Italic, highlighted, bold.", TextView.BufferType.SPANNABLE); 09.// to force it to use Spannable storage so styles can be attached. 10.// Or we could specify that in the XML. 11. 12.// Get the EditText's internal text storage 13.Spannable str = vw.getText(); 14. 15.// Create our span sections, and assign a format to each. 16.str.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, 7, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); 17.str.setSpan(new BackgroundColorSpan(0xFFFFFF00), 8, 19, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); 18.str.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 21, str.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);