@Retention(value=CLASS)
@Target(value=FIELD)
public @interface FragmentById
Use it on android.app.Fragment or android.support.v4.app.Fragment fields in activity classes to retrieve and inject a fragment.
The annotation value should be one of R.id.* fields. If not set, the field name will be used as the R.id.* field name.
Note: This can only inject an existing fragment, not create them.
Example :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="@+id/myFragment"
android:name="mypackage.MyFragment_"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
@EActivity(R.layout.main)
public class MyActivity extends Activity {
// all injected fragment will be the same
@FragmentById
public MyFragment myFragment;
@FragmentById(R.id.myFragment)
public MyFragment myFragment2;
}
EFragment,
FragmentArg,
FragmentByTagCopyright © 2010-2014. All Rights Reserved.