Inexplicable ListView


I have found these forums quite helpful, hopefully my situation will help others.

As mentioned before, Android Studio now defaults activities to The benefits of this are many as it cleans up some of the compatibility code required in this chapter, etc.

With this in mind, my SingleFragmentActivity and CrimePagerActivity both implement ActionBarActivity. After this change, I receive an exception when creating a CrimeFragment:

java.lang.RuntimeException: Your content must have a ListView whose id attribute is '' at at at at at at at at at at at at android.view.View.measure( at android.view.ViewGroup.measureChildWithMargins( at android.widget.FrameLayout.onMeasure(

To solve the problem, I added to fragment_crime.xml:

<ListView android:id="@id/android:list" android:layout_width="match_parent" android:layout_height="wrap_content" > </ListView>

This seems rather silly. When the view is inflated, the list is empty; it has no effect on the view at all. Unfortunately the addition of the ListView is the only way I can avoid the aforementioned runtime error. I’m hoping someone with more experience than I, can explain to me the reasoning for this.


Does your CrimeFragment extend ListFragment? It should be just a normal Fragment. ListFragment requires you to have a list in the layout you inflate IIRC.


That did the trick, thanks.