@Retention(value=CLASS)
@Target(value=FIELD)
public @interface FragmentByTag
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 fragment tag. If not set, the field name will be used as the tag 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:tag="myFragmentTag" 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 @FragmentByTag public MyFragment myFragmentTag; @FragmentByTag("myFragmentTag") public MyFragment myFragmentTag2; }
EFragment
,
FragmentArg
,
FragmentById
Modifier and Type | Optional Element and Description |
---|---|
java.lang.String |
value |
Copyright © 2010-2014. All Rights Reserved.