Google Android Custom Widget RichEdit - 1
I developed two custom widgets for ZInfo.
One is called RichText that can show links with custom display text, rather than the link itself.
The other is a more powerful dialog. It will be discussed later.
Android provides a widget called TextView with auto link feature.
That means you can show this:
This is http://zeaster.com/blog/
but, how to show this:
This is my blog.
How to show a link with custom display text?
RichText helps us in this way:
RichText rt = (RichText) findViewById(R.id.rich_text);
StringBuilder sb = new StringBuilder();
sb.append("This is a demo about how to use RichText.\n");
sb.append("a custom android widegt show links with custom display text, rather than the link itself.\n");
sb.append("This is <a href='http://zeaster.com/blog'>my blog</a>\n");
sb.append("This is <a href='http://infosword.com/zinfo'>ZInfo</a>\n");
rt.setRichText(sb.toString());
With this code, you got:
SpannableString is used in RichText to show custom style.
For more details, check its source code.
No comments:
Post a Comment