Code example for StyleSpan

0
			 
				int ini = txtTexto.getSelectionStart();
				int fin = txtTexto.getSelectionEnd();
				 
				texto.setSpan(
						new StyleSpan(android.graphics.Typeface.BOLD), 
						ini, fin, 
						Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
			} 
		}); 
         
        btnSetText = (Button)findViewById(R.id.BtnSetText);
        btnSetText.setOnClickListener(new View.OnClickListener() {
			public void onClick(View arg0)
			{ 
				Editable str = Editable.Factory.getInstance().newEditable("Esto es un simulacro.");
				str.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 11, 20, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
				txtTexto.setText(str);
				 
				//Nueva cadena de texto 
				//String nuevoTexto = "<p>Otro <b>texto</b> de ejemplo.</p>";