您的位置:首页 > 移动开发 > Android开发

AndroidAnnotations——Injecting FragmentArg注入Fragment参数

2014-04-06 15:47 489 查看
目录(?)[+]

FragmentArg

FragmentArg

本文档的简单示例下载

FragmentArg

Since AndroidAnnotations 2.7


@FragmentArg

The
@FragmentArg
annotation indicates that a fragment field should be injected with the corresponding

Fragment Argument.

@FragmentArg

注解表明Fragment字段应该由相应的Fragment Argument注入。

The setter method in the generated builder will always have the same name as the argument. By default, the key used to bind the value is the field name, but you can change it by providing a value to the
@FragmentArg

annotation.

生成的构造器中的setter方法的命名会一直和参数一样。以往在默认情况下,键根据字段名绑定值,但是现在你可以通过提供一个值给
@FragmentArg

注解来改变这个现状。

Usage example:用例:

@EFragment
public class MyFragment extends Fragment {
@FragmentArg("myStringArgument")
String myMessage;
@FragmentArg
String anotherStringArgument;
@FragmentArg("myDateExtra")
Date myDateArgumentWithDefaultValue = new Date();

}


The fragment builder will hold dedicated methods for these arguments:
Fragment构造器对这些参数提供了专门的方法:

MyFragment myFragment = MyFragment_.builder()
.myMessage("Hello")
.anotherStringArgument("World")
.build();

本文档的简单示例下载

本例子仅改写android Master/Detail Flow模板项目
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: