码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-04-22 13:12:17      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:layout   net   pac   ace   lse   add   extend   设置   ack   

? ??上一篇我们简单的介绍了一下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)

标签:layout   net   pac   ace   lse   add   extend   设置   ack   

原文地址:https://www.cnblogs.com/llguanli/p/8905842.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!