1

My searchable dictionary (Google's SearchableDictionary found on SDK/samples) gets its query result from SQLiteDatabase which gets data from definitions.txt file (Its .txt file not XML file).

Now I want want to show query results output as Html on android. that mean, I want to ad \n <b> and other Html code on definitions.txt which will prossesed on SQLiteDatabase give output on query. I've found a code .setText(Html.fromHtml but it supposed to work on XML strings only.

Here is My code which shows final output on my project

TextView word = (TextView) findViewById(R.id.word);
TextView definition = (TextView) findViewById(R.id.definition);
AndreyAkinshin
  • 17,047
  • 25
  • 91
  • 148
Tanzil
  • 101
  • 2
  • 3
  • 10

1 Answers1

0

You need to:

  • fetch the text you need

  • append html tags to your text

  • encode the string to html format - See Tip 1 below.

  • display the encoded html in a textview (WebView if you want to render the HTML) - See Tip 2 below.

Tip 1: You can use the htmlEnode() method from TextUtils class to encode a string to HTML. See tutorial here.

Tip 2: See this thread to find out how to load HTML encoded data into a webview.

Community
  • 1
  • 1
Anup Cowkur
  • 19,813
  • 6
  • 48
  • 82