Fragment:

@EActivity(R.layout.fragments)
public class MyFragmentActivity extends FragmentActivity {
@FragmentById
MyFragment myFragment; @FragmentById(R.id.myFragment)
MyFragment myFragment2; @FragmentByTag
MyFragment myFragmentTag; @FragmentByTag("myFragmentTag")
MyFragment myFragmentTag2;
}

在布局中使用Fragment:

<fragment
// i only display name property , you should add more
android:name="com.company.MyFragment_" />

代码中使用:

MyFragment fragment = new MyFragment_();

如果需要重写onCreateView方法,你应该:

@EFragment(R.layout.my_fragment_layout)
public class MyFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return null;
}
}

@FragmentArg

@EFragment
public class MyFragment extends Fragment {
@FragmentArg("myStringArgument")
String myMessage;
@FragmentArg
String anotherStringArgument;
@FragmentArg("myDateExtra")
Date myDateArgumentWithDefaultValue = new Date();
}
MyFragment myFragment = MyFragment_.builder()
.myMessage("Hello")
.anotherStringArgument("World")
.build();

BroadcastReciver:

@EReceiver
public class MyReceiver extends BroadcastReceiver {}

ContentProvider:

@EProvider
public class MyContentProvider extends ContentProvider {}

Service:

@EService
public class MyService extends Service {}

自定义View:

@EView
public class CustomButton extends Button {
@App
MyApplication application;
@StringRes
String someStringResource;
public CustomButton(Context context, AttributeSet attrs) {
super(context, attrs);
}
}

布局中使用自定义View:

<com.androidannotations.view.CustomButton_
android:layout_width="match_parent"
android:layout_height="wrap_content" />

代码中使用自定义View:

CustomButton button = CustomButton_.build(context);

Andorid之Annotation框架初使用(二)的更多相关文章

  1. Andorid之Annotation框架初使用(六)

    EVENT @Click :点击事件,只能有0个或1个参数,且参数为View @Click(R.id.myButton) void myButtonWasClicked() { [...] } @Cl ...

  2. Andorid之Annotation框架初使用(七)

    Save Instance State:程序保留Activity的实例状态 , 在onSaveInstanceState(Bundle)被系统调用的时候自动保存 , onCreate(Bundle)被 ...

  3. Andorid之Annotation框架初使用(五)

    注入res文件夹的资源: @StringRes @EActivity public class MyActivity extends Activity { @StringRes(R.string.he ...

  4. Andorid之Annotation框架初使用(四)

    代替繁琐的finViewById @EActivity public class MyActivity extends Activity { // Injects R.id.myEditText @V ...

  5. Andorid之Annotation框架初使用(三)

    线程使用: @Background这个是使用了cached thread pool executor , 阻止开启过多的线程 可以为@Background指定一个id,用于随时终止线程的操作(Back ...

  6. Andorid之Annotation框架初使用(一)

    1. 设置Activity的布局 @EActivity(R.layout.main) public class MyActivity extends Activity {} 注: 此时在Android ...

  7. AVFoundation 框架初探究(二)

    接着第一篇总结 系列第一篇地址:AVFoundation 框架初探究(一) 在第一篇的文章中,我们总结了主要有下面几个点的知识: 1.对AVFoundation框架整体的一个认识 2.AVSpeech ...

  8. 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建二:配置MyBatis 并测试(2 配置spring-dao和测试)

    用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建二:配置MyBatis 并测试(1 搭建目录环境和依赖) 四:在\resources\spring 下面 ...

  9. Shiro 安全框架详解二(概念+权限案例实现)

    Shiro 安全框架详解二 总结内容 一.登录认证 二.Shiro 授权 1. 概念 2. 授权流程图 三.基于 ini 的授权认证案例实现 1. 实现原理图 2. 实现代码 2.1 添加 maven ...

随机推荐

  1. poj 2337(单向欧拉路的判断以及输出)

    Catenyms Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11648   Accepted: 3036 Descrip ...

  2. day4 正则表达式(regular)

    正则(regular),要使用正则表达式需要导入Python中的re(regular正则的缩写)模块.正则表达式是对字符串的处理,我们知道,字符串中有时候包含很多我们想要提取的信息,掌握这些处理字符串 ...

  3. git与pycharm合并,珠联璧合

    前段时间提交代码都是各种手写push push push,好蠢,今天尝试了一下ide直接提交,爽的一匹,做个总结. 首先github帐号肯定要有. 看图,设置好帐号啥的 再设置git路径,这个应该自动 ...

  4. 搭建简单的CGI应用程序

    原文来源于<核心编程3>第10章web编程 一.静态文件+脚本文件 1.首先开启cgiweb服务器 python2 -m CGIHTTPServer 8000 看到如下反应 2.服务器目录 ...

  5. 【UOJ】#79. 一般图最大匹配

    题解 板子!我相信其实没人来看我的板子!但是为了防止我忘记,我还是要写点什么 我们考虑二分图,为什么二分图就能那么轻松地写出匹配的代码呢?因为匹配只会发生在黑点和白点之间,我们找寻增广路,必然是一黑一 ...

  6. oracle创建简单的包

    --规范 create or replace package test_pkg is --test_pkg为包名 procedure showMessage; --声明一个过程 function my ...

  7. 洛谷P2047 [NOI2007]社交网络 [图论,最短路计数]

    题目传送门 社交网络 题目描述 在社交网络(social network)的研究中,我们常常使用图论概念去解释一些社会现象.不妨看这样的一个问题.在一个社交圈子里有n个人,人与人之间有不同程度的关系. ...

  8. mysql总是无故退出, InnoDB: mmap(68681728 bytes) failed; errno 12

    最近发现mysql总是无故退出,(vim /var/log/mysqld.log)查看日志报下面错误: InnoDB: mmap(68681728 bytes) failed; errno 12 开启 ...

  9. 初始Hibernate4

    Hibernate是一个ORM的轻量级框架,解决持久化操作,使得程序员可以从编写繁复的jdbc的工作中解放出来,专注与业务,提高我们的开发效率.移植性. 1.持久化    a) 侠义概念:数据存储在物 ...

  10. 【插头DP】BZOJ3125-city

    开学忙成狗,刷题慢如蜗牛…… [题目大意] 给出一个m*n的矩阵里面有一些格子为障碍物,一些格子只能上下通行,一些格子只能左右通行,一些格子上下左右都能通行.问经过所有非障碍格子的哈密顿回路个数. [ ...