I've been trying to get Roboguice to work with fragments declared in a <fragment>
block in the layout file and then injected into the activity, but, although the fragment exists somewhere off screen (an EditText
in the fragment takes focus and fires events), It is not visible. Does RoboGuice support what I'm trying to do here or should I go about it a different way?
code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/myFragment"
android:name="com.example.MyFragment"
android:layout_height="0dp"
android:layout_width="0dp"
android:layout_weight="1" >
<!-- Preview: layout=@layout/my_fragment -->
</fragment>
</LinearLayout>
Java:
@ContentView(R.layout.participant)
public final class Main extends RoboFragmentActivity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@InjectFragment(R.id.myFragment) private MyFragment myFragment;
}