Si può anche fare questo tramite il file /res/values/string.xml, se si preferisce: ad esempio, nel /res/values/string.xml voi potrebbe aggiungere una voce del tipo:
<string name="createAccount"><u>Create Account</u></string>
E poi nel metodo onCreate (Bundle savedInstanceState) della vostra attività si dovrebbe aggiungere il seguente codice per causare "Create account"> appaia come sottolineato nell'interfaccia utente che si imposta per il createAccountText TextView che hai definito nel file xml in/res/layout/per la tua attività:
TextView createAccountText = (TextView) findViewById(R.id.createAccountText);
Resources res = getResources();
CharSequence styledText = res.getText(R.string.createAccount);
createAccountText.setText(styledText, TextView.BufferType.SPANNABLE);
Danny Remington - MacroSolve
fonte
2011-01-26 16:45:48
La soluzione più semplice IMHO. – gnac
Questo non funzionerà perché la parentesi di apertura dei tag '' e '' non è sottoposta a escape. Per un esempio corretto, vedere http://stackoverflow.com/a/9955051/425183 – Ognyan
soluzione più semplice, txs – Hubert