首页 > 其他 > 详细

【八】注入框架RoboGuice使用:(Your First Injected Fragment)

时间:2014-10-27 19:30:09      阅读:171      评论:0      收藏:0      [点我收藏+]

    上一篇我们简单的介绍了一下RoboGuice的使用(【七】注入框架RoboGuice使用:(Your First Custom Binding)),今天我们来看下fragment的注解

   (一):简介:和Activity一样,我们也同样可以在Fragment中使用注解,你需要一下的步骤.

          ①:编写一个继承与RoboFragment的Fragment;

          ②:设置你的布局(如果使用View注入)

          ③:注入你的View空间,资源文件(Resources),对象等等

   (二):例子:

public class MyFragment extends RoboFragment {
    // Inject your view
    @InjectView(R.id.text1) TextView nameTextView;

    // Inflate your view as you normally would for any fragment...
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.my_layout, container, false);
    }
  }
   (三):兼容

  现在RoboGuice 3.0版本已经支持原生以及兼容Fragment,他们分别位于包名如下:

  • package roboguice.fragment (for support fragments)
  • package roboguice.fragment.provided (for native android SDK 11+ fragments)

【八】注入框架RoboGuice使用:(Your First Injected Fragment)

原文:http://blog.csdn.net/developer_jiangqq/article/details/40512297

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!