Loading

Saturday, August 13, 2011

Html-encode string using TextUtils.htmlEncode()

In order to convert string to html format, we can use htmlEncode() method of TextUtils class.



Html-encode string using TextUtils.htmlEncode()



package com.exercise.AndroidHtmlEncode;



import android.app.Activity;

import android.os.Bundle;

import android.text.TextUtils;

import android.widget.TextView;



public class AndroidHtmlEncodeActivity extends Activity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);



TextView textSrc = (TextView)findViewById(R.id.src);

TextView textDest = (TextView)findViewById(R.id.dest);



String src = "example: <activity>";

String dest = TextUtils.htmlEncode(src);



textSrc.setText(src);

textDest.setText(dest);

}

}








SHARE TWEET

Thank you for reading this article Html-encode string using TextUtils.htmlEncode() With URL http://x-tutorials.blogspot.com/2011/08/html-encode-string-using.html. Also a time to read the other articles.

0 comments:

Write your comment for this article Html-encode string using TextUtils.htmlEncode() above!