Add highlights to span's from pregenerated html

atmdt

New Member
Hello i can't figure out how to use the span's that are in the styledText String and add highlights to only the words in those span's.Does anyone know how to do this?\[code\] public class ArticleActivity extends Activity{ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_article); TextView textview = new TextView(this); String styledText = "Vanwege een verdacht koffertje <span id=\"txt8264:idx8:tkn41:cls1\" class=\"supported dictionary\">is</span> vanochtend een tankstation langs <span id=\"txt8264:idx18:tkn4:cls11\" class=\"supported dictionary\">de</span> A16 bij Hazeldonk korte tijd afgesloten <span id=\"txt8264:idx32:tkn1156:cls1\" class=\"supported dictionary\">geweest</span>.<br/><br/>Volgens <span id=\"txt8264:idx37:tkn4:cls11\" class=\"supported dictionary\">de</span> politie stapte een man uit zijn auto en zette hij <span id=\"txt8264:idx59:tkn98:cls11\" class=\"supported dictionary\">het</span> koffertje naast <span id=\"txt8264:idx65:tkn98:cls11\" class=\"supported dictionary\">het</span> tankstation neer. Daarna reed hij weg.<br/><br/>Een explosievenverkenner van <span id=\"txt8264:idx87:tkn4:cls11\" class=\"supported dictionary\">de</span> politie onderzocht <span id=\"txt8264:idx93:tkn98:cls11\" class=\"supported dictionary\">het</span> koffertje en constateerde dat <span id=\"txt8264:idx103:tkn98:cls11\" class=\"supported dictionary\">het</span> leeg was. <span id=\"txt8264:idx110:tkn66:cls11\" class=\"supported dictionary\">Het</span> tankstation werd korte tijd later weer vrijgegeven. <span id=\"txt8264:idx127:tkn25:cls11\" class=\"supported dictionary\">De</span> afsluiting <span id=\"txt8264:idx131:tkn404:cls1\" class=\"supported dictionary\">had</span> geen gevolgen voor <span id=\"txt8264:idx139:tkn98:cls11\" class=\"supported dictionary\">het</span> verkeer op <span id=\"txt8264:idx145:tkn4:cls11\" class=\"supported dictionary\">de</span> A16 bij <span id=\"txt8264:idx151:tkn4:cls11\" class=\"supported dictionary\">de</span> grensovergang met Belgi?.<br/><br/>Ook <span id=\"txt8264:idx162:tkn4:cls11\" class=\"supported dictionary\">de</span> parkeerplaats achter <span id=\"txt8264:idx168:tkn98:cls11\" class=\"supported dictionary\">het</span> tankstation <span id=\"txt8264:idx172:tkn215:cls1\" class=\"supported dictionary\">was</span> bereikbaar.<br/><br/>"; textview.setText(Html.fromHtml(styledText), TextView.BufferType.SPANNABLE); setContentView(textview); } }\[/code\]
 
Back
Top