2

I Have an HTML Text.

Sales Resources

  • Drive to Collab Partner Presentation
  • Drive to Collab Program FAQs
  • Platform for Voice and Video Campaign

I would like to display this text in Android Text View. I have tried MyTagHandler to display, it is working fine while displaying, but the text formating is not good. If the bulleted text has 2 lines then the second line is coming from first, but i need space upto bullet. how can i handle this? Problem Image

1

2 Answers 2

2

i guess like this...

TextView foo = (TextView)findViewById(R.id.foo);
foo.setText(Html.fromHtml("your html text"));
Sign up to request clarification or add additional context in comments.

Comments

1

You can do that in 2 ways.

  1. First you create a HTML Script for it.

Once you are done with it, then set that to textview as shown below. (preferable for smaller text)

myTextView.setText(Html.fromHtml("Html Script"));
  1. Create a html file and put it in res/raw.

Then use the follwoing code.

myTextView.setText(Html.fromHtml(getHtmlText())); 

Now define getHtmlText() method as below:

private String getHtmlText(){
 InputStream inputStream = getResources().openRawResource(R.raw.my_html_file);
 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
 int i;
 try {
 i = inputStream.read();
  while (i != -1)
  {
   byteArrayOutputStream.write(i);
   i = inputStream.read();
  }
  inputStream.close();
  } catch (IOException e) {
 // TODO Auto-generated catch block
 e.printStackTrace();
 }
  return byteArrayOutputStream.toString();
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.