AndroidAnnotations——Injecting html注入html文本
2014-04-06 15:44
218 查看
2013-12-04 20:16109人阅读评论(0)收藏举报
AndroidAnnotation
目录(?)[+]
Injecting html注入html
HtmlRes
FromHtml
本文档的简单示例下载
If you want to inject HTML text in a
假如你想在
控件中注入HTML文本(可能它需要格式化,或者因为你喜欢HTML),有两个注解可以帮助你:
Let's say you have the following string resource:
让我们假设你有以下的string资源:
This annotation acts as
@StringRes (retrieves a
这个注解表现的和 @StringRes
类似(获取
资源)并调用
Note that
实现了
This annotation must be used on a
这个注解必须在加了
上使用。它的目的是设置HTML文本到TextView上:
AndroidAnnotation
目录(?)[+]
Injecting html注入html
HtmlRes
FromHtml
本文档的简单示例下载
Injecting html注入html
Since AndroidAnnotations 2.2If you want to inject HTML text in a
TextView(may it be to format it or because you love HTML), there are two annotations that can help you:
假如你想在
TextView
控件中注入HTML文本(可能它需要格式化,或者因为你喜欢HTML),有两个注解可以帮助你:
@FromHtml
@HtmlRes
Let's say you have the following string resource:
让我们假设你有以下的string资源:
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello_html"><![CDATA[Hello <b>World</b>!]]></string> </resources>
@HtmlRes
This annotation acts as@StringRes (retrieves a
Stringresource) and wraps the result with a call to
HTML.fromHtml():
这个注解表现的和 @StringRes
类似(获取
String
资源)并调用
HTML.fromHtml()覆盖结果。
@EActivity public class MyActivity extends Activity { // Injects R.string.hello_html @HtmlRes(R.string.hello_html) Spanned myHelloString; // Also injects R.string.hello_html @HtmlRes CharSequence helloHtml; }
Note that
Spannedimplements
CharSequence, thus you can use both for a
@HtmlRes.请注意
Spanned
实现了
CharSequence,因此你可以用
@HtmlRes注解它们。
@FromHtml
This annotation must be used on a TextViewalready annotated with
@ViewById. The purpose of this annotation is to set HTML text in a TextView:
这个注解必须在加了
@ViewById注解的
TextView
上使用。它的目的是设置HTML文本到TextView上:
@EActivity
public class MyActivity extends Activity {
@ViewById(R.id.my_text_view)
@FromHtml(R.string.hello_html)TextView textView;
// Injects R.string.hello_html into the R.id.hello_html view@ViewById
@FromHtmlTextView helloHtml;
}
本文档的简单示例下载
相关文章推荐
- AndroidAnnotations——Injecting html注入html文本
- AndroidAnnotations——Injecting project Resources注入项目资源
- AndroidAnnotations——Injecting SystemServices注入系统服务
- AndroidAnnotations——Injecting FragmentArg注入Fragment参数
- AndroidAnnotations——Injecting FragmentArg注入Fragment参数
- AndroidAnnotations——Injecting project Resources注入项目资源
- AndroidAnnotations——Injecting SystemServices注入系统服务
- AndroidAnnotations——Injecting FragmentArg注入Fragment参数
- AndroidAnnotations——Injecting Views视图注入
- Android中Textview显示带html文本一-------【HTML标签】
- Dagger,ButterKnife,Roboguide,AndroidAnnotations框架的依赖注入浅析
- Android Textview显示带html文本及本地图片
- Android WebView加载Html文本不能适配,以及图片中间有空白的问题
- AndroidAnnotations——Injecting Extras注入Extras
- android富文本 加载带图片的html<drawable为null的bug>
- Android中Textview显示带html文本二
- Android跨进程事件注入 Injecting to another application requires INJECT_EVENTS permission
- Android中Textview显示带html文本一-------【HTML标签】
- AndroidAnnotations——Reinject NonConfiguration Instance重新注入NonConfiguration 实例
- Android中Textview显示带html文本【Textview显示本地图片】