1

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;
}
JRaymond
  • 11,625
  • 5
  • 37
  • 40

1 Answers1

1

Solved the issue, but for anyone else looking - The issue at hand was completely unrelated to RoboGuice, which allows fragment injection exactly as shown above. Rather the issue was that both of my layout dimensions for the fragment were set to 0dp, ensuring that my fragment would never be rendered.

JRaymond
  • 11,625
  • 5
  • 37
  • 40